OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/graph-inl.h" | 7 #include "src/compiler/graph-inl.h" |
8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-aux-data-inl.h" | 10 #include "src/compiler/node-aux-data-inl.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 template <typename T> | 22 template <typename T> |
23 static CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate, | 23 static CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate, |
24 T* stub) { | 24 T* stub) { |
25 CodeStub::Major key = static_cast<CodeStub*>(stub)->MajorKey(); | 25 CodeStub::Major key = static_cast<CodeStub*>(stub)->MajorKey(); |
26 CodeStubInterfaceDescriptor* d = isolate->code_stub_interface_descriptor(key); | 26 CodeStubInterfaceDescriptor* d = isolate->code_stub_interface_descriptor(key); |
27 stub->InitializeInterfaceDescriptor(d); | 27 stub->InitializeInterfaceDescriptor(d); |
28 return d; | 28 return d; |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 // TODO(mstarzinger): This is a temporary shim to be able to call an IC stub | |
33 // which doesn't have an interface descriptor yet. It mimics a hydrogen code | |
34 // stub for the underlying IC stub code. | |
35 class LoadICStubShim : public HydrogenCodeStub { | |
36 public: | |
37 LoadICStubShim(Isolate* isolate, ContextualMode contextual_mode) | |
38 : HydrogenCodeStub(isolate), contextual_mode_(contextual_mode) { | |
39 i::compiler::GetInterfaceDescriptor(isolate, this); | |
40 } | |
41 | |
42 virtual Handle<Code> GenerateCode() V8_OVERRIDE { | |
43 ExtraICState extra_state = LoadIC::ComputeExtraICState(contextual_mode_); | |
44 return LoadIC::initialize_stub(isolate(), extra_state); | |
45 } | |
46 | |
47 virtual void InitializeInterfaceDescriptor( | |
48 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE { | |
49 Register registers[] = { InterfaceDescriptor::ContextRegister(), | |
50 LoadIC::ReceiverRegister(), | |
51 LoadIC::NameRegister() }; | |
52 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); | |
53 } | |
54 | |
55 private: | |
56 virtual Major MajorKey() const V8_OVERRIDE { return NoCache; } | |
57 virtual int NotMissMinorKey() const V8_OVERRIDE { return 0; } | |
58 virtual bool UseSpecialCache() V8_OVERRIDE { return true; } | |
59 | |
60 ContextualMode contextual_mode_; | |
61 }; | |
62 | |
63 | |
64 // TODO(mstarzinger): This is a temporary shim to be able to call an IC stub | |
65 // which doesn't have an interface descriptor yet. It mimics a hydrogen code | |
66 // stub for the underlying IC stub code. | |
67 class KeyedLoadICStubShim : public HydrogenCodeStub { | |
68 public: | |
69 explicit KeyedLoadICStubShim(Isolate* isolate) : HydrogenCodeStub(isolate) { | |
70 i::compiler::GetInterfaceDescriptor(isolate, this); | |
71 } | |
72 | |
73 virtual Handle<Code> GenerateCode() V8_OVERRIDE { | |
74 return isolate()->builtins()->KeyedLoadIC_Initialize(); | |
75 } | |
76 | |
77 virtual void InitializeInterfaceDescriptor( | |
78 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE { | |
79 Register registers[] = { InterfaceDescriptor::ContextRegister(), | |
80 KeyedLoadIC::ReceiverRegister(), | |
81 KeyedLoadIC::NameRegister() }; | |
82 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); | |
83 } | |
84 | |
85 private: | |
86 virtual Major MajorKey() const V8_OVERRIDE { return NoCache; } | |
87 virtual int NotMissMinorKey() const V8_OVERRIDE { return 0; } | |
88 virtual bool UseSpecialCache() V8_OVERRIDE { return true; } | |
89 }; | |
90 | |
91 | |
92 // TODO(mstarzinger): This is a temporary shim to be able to call an IC stub | |
93 // which doesn't have an interface descriptor yet. It mimics a hydrogen code | |
94 // stub for the underlying IC stub code. | |
95 class StoreICStubShim : public HydrogenCodeStub { | |
96 public: | |
97 StoreICStubShim(Isolate* isolate, StrictMode strict_mode) | |
98 : HydrogenCodeStub(isolate), strict_mode_(strict_mode) { | |
99 i::compiler::GetInterfaceDescriptor(isolate, this); | |
100 } | |
101 | |
102 virtual Handle<Code> GenerateCode() V8_OVERRIDE { | |
103 return StoreIC::initialize_stub(isolate(), strict_mode_); | |
104 } | |
105 | |
106 virtual void InitializeInterfaceDescriptor( | |
107 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE { | |
108 Register registers[] = { InterfaceDescriptor::ContextRegister(), | |
109 StoreIC::ReceiverRegister(), | |
110 StoreIC::NameRegister(), | |
111 StoreIC::ValueRegister() }; | |
112 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); | |
113 } | |
114 | |
115 private: | |
116 virtual Major MajorKey() const V8_OVERRIDE { return NoCache; } | |
117 virtual int NotMissMinorKey() const V8_OVERRIDE { return 0; } | |
118 virtual bool UseSpecialCache() V8_OVERRIDE { return true; } | |
119 | |
120 StrictMode strict_mode_; | |
121 }; | |
122 | |
123 | |
124 // TODO(mstarzinger): This is a temporary shim to be able to call an IC stub | |
125 // which doesn't have an interface descriptor yet. It mimics a hydrogen code | |
126 // stub for the underlying IC stub code. | |
127 class KeyedStoreICStubShim : public HydrogenCodeStub { | |
128 public: | |
129 KeyedStoreICStubShim(Isolate* isolate, StrictMode strict_mode) | |
130 : HydrogenCodeStub(isolate), strict_mode_(strict_mode) { | |
131 i::compiler::GetInterfaceDescriptor(isolate, this); | |
132 } | |
133 | |
134 virtual Handle<Code> GenerateCode() V8_OVERRIDE { | |
135 return strict_mode_ == SLOPPY | |
136 ? isolate()->builtins()->KeyedStoreIC_Initialize() | |
137 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | |
138 } | |
139 | |
140 virtual void InitializeInterfaceDescriptor( | |
141 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE { | |
142 Register registers[] = { InterfaceDescriptor::ContextRegister(), | |
143 KeyedStoreIC::ReceiverRegister(), | |
144 KeyedStoreIC::NameRegister(), | |
145 KeyedStoreIC::ValueRegister() }; | |
146 descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers); | |
147 } | |
148 | |
149 private: | |
150 virtual Major MajorKey() const V8_OVERRIDE { return NoCache; } | |
151 virtual int NotMissMinorKey() const V8_OVERRIDE { return 0; } | |
152 virtual bool UseSpecialCache() V8_OVERRIDE { return true; } | |
153 | |
154 StrictMode strict_mode_; | |
155 }; | |
156 | |
157 | |
32 JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph, | 158 JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph, |
33 MachineOperatorBuilder* machine, | 159 MachineOperatorBuilder* machine, |
34 SourcePositionTable* source_positions) | 160 SourcePositionTable* source_positions) |
35 : LoweringBuilder(jsgraph->graph(), source_positions), | 161 : LoweringBuilder(jsgraph->graph(), source_positions), |
36 info_(info), | 162 info_(info), |
37 jsgraph_(jsgraph), | 163 jsgraph_(jsgraph), |
38 linkage_(new (jsgraph->zone()) Linkage(info)), | 164 linkage_(new (jsgraph->zone()) Linkage(info)), |
39 machine_(machine) {} | 165 machine_(machine) {} |
40 | 166 |
41 | 167 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 } | 415 } |
290 | 416 |
291 | 417 |
292 Node* JSGenericLowering::LowerJSToObject(Node* node) { | 418 Node* JSGenericLowering::LowerJSToObject(Node* node) { |
293 ReplaceWithBuiltinCall(node, Builtins::TO_OBJECT, 1); | 419 ReplaceWithBuiltinCall(node, Builtins::TO_OBJECT, 1); |
294 return node; | 420 return node; |
295 } | 421 } |
296 | 422 |
297 | 423 |
298 Node* JSGenericLowering::LowerJSLoadProperty(Node* node) { | 424 Node* JSGenericLowering::LowerJSLoadProperty(Node* node) { |
299 if (FLAG_compiled_keyed_generic_loads) { | 425 KeyedLoadICStubShim stub(isolate()); |
titzer
2014/08/05 12:33:27
Do we still want to respect the flag?
Michael Starzinger
2014/08/05 12:41:38
I don't think so. I only added the check because t
| |
300 KeyedLoadGenericStub stub(isolate()); | 426 ReplaceWithICStubCall(node, &stub); |
301 ReplaceWithICStubCall(node, &stub); | |
302 } else { | |
303 ReplaceWithRuntimeCall(node, Runtime::kKeyedGetProperty); | |
304 } | |
305 return node; | 427 return node; |
306 } | 428 } |
307 | 429 |
308 | 430 |
309 Node* JSGenericLowering::LowerJSLoadNamed(Node* node) { | 431 Node* JSGenericLowering::LowerJSLoadNamed(Node* node) { |
310 Node* key = | 432 PrintableUnique<Name> key = OpParameter<PrintableUnique<Name> >(node); |
311 jsgraph()->HeapConstant(OpParameter<PrintableUnique<Name> >(node)); | 433 // TODO(mstarzinger): The ContextualMode needs to be carried along in the |
312 PatchInsertInput(node, 1, key); | 434 // operator to use JSLoadNamed for global variable loads. |
313 // TODO(mstarzinger): We cannot yet use KeyedLoadGenericElementStub here, | 435 LoadICStubShim stub(isolate(), NOT_CONTEXTUAL); |
314 // because named interceptors would not fire correctly yet. | 436 PatchInsertInput(node, 1, jsgraph()->HeapConstant(key)); |
315 ReplaceWithRuntimeCall(node, Runtime::kGetProperty); | 437 ReplaceWithICStubCall(node, &stub); |
316 return node; | 438 return node; |
317 } | 439 } |
318 | 440 |
319 | 441 |
320 Node* JSGenericLowering::LowerJSStoreProperty(Node* node) { | 442 Node* JSGenericLowering::LowerJSStoreProperty(Node* node) { |
321 // TODO(mstarzinger): The strict_mode needs to be carried along in the | 443 // TODO(mstarzinger): The strict_mode needs to be carried along in the |
322 // operator so that graphs are fully compositional for inlining. | 444 // operator so that graphs are fully compositional for inlining. |
323 StrictMode strict_mode = info()->strict_mode(); | 445 StrictMode strict_mode = info()->strict_mode(); |
324 PatchInsertInput(node, 3, SmiConstant(strict_mode)); | 446 KeyedStoreICStubShim stub(isolate(), strict_mode); |
325 ReplaceWithRuntimeCall(node, Runtime::kSetProperty, 4); | 447 ReplaceWithICStubCall(node, &stub); |
326 return node; | 448 return node; |
327 } | 449 } |
328 | 450 |
329 | 451 |
330 Node* JSGenericLowering::LowerJSStoreNamed(Node* node) { | 452 Node* JSGenericLowering::LowerJSStoreNamed(Node* node) { |
453 PrintableUnique<Name> key = OpParameter<PrintableUnique<Name> >(node); | |
331 // TODO(mstarzinger): The strict_mode needs to be carried along in the | 454 // TODO(mstarzinger): The strict_mode needs to be carried along in the |
332 // operator so that graphs are fully compositional for inlining. | 455 // operator so that graphs are fully compositional for inlining. |
333 StrictMode strict_mode = info()->strict_mode(); | 456 StrictMode strict_mode = info()->strict_mode(); |
334 Node* key = | 457 StoreICStubShim stub(isolate(), strict_mode); |
335 jsgraph()->HeapConstant(OpParameter<PrintableUnique<Name> >(node)); | 458 PatchInsertInput(node, 1, jsgraph()->HeapConstant(key)); |
336 PatchInsertInput(node, 1, key); | 459 ReplaceWithICStubCall(node, &stub); |
337 PatchInsertInput(node, 3, SmiConstant(strict_mode)); | |
338 ReplaceWithRuntimeCall(node, Runtime::kSetProperty, 4); | |
339 return node; | 460 return node; |
340 } | 461 } |
341 | 462 |
342 | 463 |
343 Node* JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 464 Node* JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
344 StrictMode strict_mode = OpParameter<StrictMode>(node); | 465 StrictMode strict_mode = OpParameter<StrictMode>(node); |
345 PatchInsertInput(node, 2, SmiConstant(strict_mode)); | 466 PatchInsertInput(node, 2, SmiConstant(strict_mode)); |
346 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); | 467 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); |
347 return node; | 468 return node; |
348 } | 469 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 | 556 |
436 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { | 557 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { |
437 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); | 558 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); |
438 int arity = NodeProperties::GetValueInputCount(node); | 559 int arity = NodeProperties::GetValueInputCount(node); |
439 ReplaceWithRuntimeCall(node, function, arity); | 560 ReplaceWithRuntimeCall(node, function, arity); |
440 return node; | 561 return node; |
441 } | 562 } |
442 } | 563 } |
443 } | 564 } |
444 } // namespace v8::internal::compiler | 565 } // namespace v8::internal::compiler |
OLD | NEW |