• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/builtins/builtins-utils-gen.h"
6 #include "src/builtins/builtins.h"
7 #include "src/code-stub-assembler.h"
8 #include "src/ic/ic.h"
9 #include "src/ic/keyed-store-generic.h"
10 #include "src/objects-inl.h"
11 
12 namespace v8 {
13 namespace internal {
14 
TF_BUILTIN(LoadIC_StringLength,CodeStubAssembler)15 TF_BUILTIN(LoadIC_StringLength, CodeStubAssembler) {
16   Node* string = Parameter(Descriptor::kReceiver);
17   Return(LoadStringLengthAsSmi(string));
18 }
19 
TF_BUILTIN(LoadIC_StringWrapperLength,CodeStubAssembler)20 TF_BUILTIN(LoadIC_StringWrapperLength, CodeStubAssembler) {
21   Node* value = Parameter(Descriptor::kReceiver);
22   Node* string = LoadJSValueValue(value);
23   Return(LoadStringLengthAsSmi(string));
24 }
25 
TF_BUILTIN(KeyedLoadIC_Slow,CodeStubAssembler)26 TF_BUILTIN(KeyedLoadIC_Slow, CodeStubAssembler) {
27   Node* receiver = Parameter(Descriptor::kReceiver);
28   Node* name = Parameter(Descriptor::kName);
29   Node* context = Parameter(Descriptor::kContext);
30 
31   TailCallRuntime(Runtime::kKeyedGetProperty, context, receiver, name);
32 }
33 
Generate_KeyedStoreIC_Megamorphic(compiler::CodeAssemblerState * state)34 void Builtins::Generate_KeyedStoreIC_Megamorphic(
35     compiler::CodeAssemblerState* state) {
36   KeyedStoreGenericGenerator::Generate(state);
37 }
38 
Generate_StoreIC_Uninitialized(compiler::CodeAssemblerState * state)39 void Builtins::Generate_StoreIC_Uninitialized(
40     compiler::CodeAssemblerState* state) {
41   StoreICUninitializedGenerator::Generate(state);
42 }
43 
TF_BUILTIN(KeyedStoreIC_Slow,CodeStubAssembler)44 TF_BUILTIN(KeyedStoreIC_Slow, CodeStubAssembler) {
45   Node* receiver = Parameter(Descriptor::kReceiver);
46   Node* name = Parameter(Descriptor::kName);
47   Node* value = Parameter(Descriptor::kValue);
48   Node* slot = Parameter(Descriptor::kSlot);
49   Node* vector = Parameter(Descriptor::kVector);
50   Node* context = Parameter(Descriptor::kContext);
51 
52   // The slow case calls into the runtime to complete the store without causing
53   // an IC miss that would otherwise cause a transition to the generic stub.
54   TailCallRuntime(Runtime::kKeyedStoreIC_Slow, context, value, slot, vector,
55                   receiver, name);
56 }
57 
TF_BUILTIN(StoreInArrayLiteralIC_Slow,CodeStubAssembler)58 TF_BUILTIN(StoreInArrayLiteralIC_Slow, CodeStubAssembler) {
59   Node* array = Parameter(Descriptor::kReceiver);
60   Node* index = Parameter(Descriptor::kName);
61   Node* value = Parameter(Descriptor::kValue);
62   Node* context = Parameter(Descriptor::kContext);
63   TailCallRuntime(Runtime::kStoreInArrayLiteralIC_Slow, context, value, array,
64                   index);
65 }
66 
TF_BUILTIN(LoadGlobalIC_Slow,CodeStubAssembler)67 TF_BUILTIN(LoadGlobalIC_Slow, CodeStubAssembler) {
68   Node* name = Parameter(Descriptor::kName);
69   Node* slot = Parameter(Descriptor::kSlot);
70   Node* vector = Parameter(Descriptor::kVector);
71   Node* context = Parameter(Descriptor::kContext);
72 
73   TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, name, slot, vector);
74 }
75 
TF_BUILTIN(LoadIC_FunctionPrototype,CodeStubAssembler)76 TF_BUILTIN(LoadIC_FunctionPrototype, CodeStubAssembler) {
77   Node* receiver = Parameter(Descriptor::kReceiver);
78   Node* name = Parameter(Descriptor::kName);
79   Node* slot = Parameter(Descriptor::kSlot);
80   Node* vector = Parameter(Descriptor::kVector);
81   Node* context = Parameter(Descriptor::kContext);
82 
83   Label miss(this, Label::kDeferred);
84   Return(LoadJSFunctionPrototype(receiver, &miss));
85 
86   BIND(&miss);
87   TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name, slot, vector);
88 }
89 
TF_BUILTIN(LoadIC_Slow,CodeStubAssembler)90 TF_BUILTIN(LoadIC_Slow, CodeStubAssembler) {
91   Node* receiver = Parameter(Descriptor::kReceiver);
92   Node* name = Parameter(Descriptor::kName);
93   Node* context = Parameter(Descriptor::kContext);
94 
95   TailCallRuntime(Runtime::kGetProperty, context, receiver, name);
96 }
97 
TF_BUILTIN(StoreGlobalIC_Slow,CodeStubAssembler)98 TF_BUILTIN(StoreGlobalIC_Slow, CodeStubAssembler) {
99   Node* receiver = Parameter(Descriptor::kReceiver);
100   Node* name = Parameter(Descriptor::kName);
101   Node* value = Parameter(Descriptor::kValue);
102   Node* slot = Parameter(Descriptor::kSlot);
103   Node* vector = Parameter(Descriptor::kVector);
104   Node* context = Parameter(Descriptor::kContext);
105 
106   // The slow case calls into the runtime to complete the store without causing
107   // an IC miss that would otherwise cause a transition to the generic stub.
108   TailCallRuntime(Runtime::kStoreGlobalIC_Slow, context, value, slot, vector,
109                   receiver, name);
110 }
111 
112 }  // namespace internal
113 }  // namespace v8
114