| 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-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 CallDescriptor::Flags flags) { | 207 CallDescriptor::Flags flags) { |
| 208 Operator::Properties properties = node->op()->properties(); | 208 Operator::Properties properties = node->op()->properties(); |
| 209 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 209 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 210 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 210 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
| 211 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 211 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 212 node->InsertInput(zone(), 0, stub_code); | 212 node->InsertInput(zone(), 0, stub_code); |
| 213 node->set_op(common()->Call(desc)); | 213 node->set_op(common()->Call(desc)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, | 217 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, int context_index, |
| 218 Builtins::JavaScript id, | |
| 219 int nargs) { | 218 int nargs) { |
| 220 Node* context_input = NodeProperties::GetContextInput(node); | 219 Node* context_input = NodeProperties::GetContextInput(node); |
| 221 Node* effect_input = NodeProperties::GetEffectInput(node); | 220 Node* effect_input = NodeProperties::GetEffectInput(node); |
| 222 | 221 |
| 223 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 222 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 224 Operator::Properties properties = node->op()->properties(); | 223 Operator::Properties properties = node->op()->properties(); |
| 225 Callable callable = | 224 Callable callable = |
| 226 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | 225 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); |
| 227 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 226 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 228 isolate(), zone(), callable.descriptor(), nargs, flags, properties); | 227 isolate(), zone(), callable.descriptor(), nargs, flags, properties); |
| 229 Node* global_object = | 228 Node* global_object = |
| 230 graph()->NewNode(machine()->Load(kMachAnyTagged), context_input, | 229 graph()->NewNode(machine()->Load(kMachAnyTagged), context_input, |
| 231 jsgraph()->IntPtrConstant( | 230 jsgraph()->IntPtrConstant( |
| 232 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)), | 231 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)), |
| 233 effect_input, graph()->start()); | 232 effect_input, graph()->start()); |
| 234 Node* builtins_object = graph()->NewNode( | 233 Node* native_context = |
| 235 machine()->Load(kMachAnyTagged), global_object, | 234 graph()->NewNode(machine()->Load(kMachAnyTagged), global_object, |
| 236 jsgraph()->IntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag), | 235 jsgraph()->IntPtrConstant( |
| 237 effect_input, graph()->start()); | 236 GlobalObject::kNativeContextOffset - kHeapObjectTag), |
| 237 effect_input, graph()->start()); |
| 238 Node* function = graph()->NewNode( | 238 Node* function = graph()->NewNode( |
| 239 machine()->Load(kMachAnyTagged), builtins_object, | 239 machine()->Load(kMachAnyTagged), native_context, |
| 240 jsgraph()->IntPtrConstant(JSBuiltinsObject::OffsetOfFunctionWithId(id) - | 240 jsgraph()->IntPtrConstant(Context::SlotOffset(context_index)), |
| 241 kHeapObjectTag), | |
| 242 effect_input, graph()->start()); | 241 effect_input, graph()->start()); |
| 243 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 242 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 244 node->InsertInput(zone(), 0, stub_code); | 243 node->InsertInput(zone(), 0, stub_code); |
| 245 node->InsertInput(zone(), 1, function); | 244 node->InsertInput(zone(), 1, function); |
| 246 node->set_op(common()->Call(desc)); | 245 node->set_op(common()->Call(desc)); |
| 247 } | 246 } |
| 248 | 247 |
| 249 | 248 |
| 250 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 249 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
| 251 Runtime::FunctionId f, | 250 Runtime::FunctionId f, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 289 |
| 291 | 290 |
| 292 void JSGenericLowering::LowerJSToNumber(Node* node) { | 291 void JSGenericLowering::LowerJSToNumber(Node* node) { |
| 293 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 292 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 294 Callable callable = CodeFactory::ToNumber(isolate()); | 293 Callable callable = CodeFactory::ToNumber(isolate()); |
| 295 ReplaceWithStubCall(node, callable, flags); | 294 ReplaceWithStubCall(node, callable, flags); |
| 296 } | 295 } |
| 297 | 296 |
| 298 | 297 |
| 299 void JSGenericLowering::LowerJSToString(Node* node) { | 298 void JSGenericLowering::LowerJSToString(Node* node) { |
| 300 ReplaceWithBuiltinCall(node, Builtins::TO_STRING, 1); | 299 ReplaceWithBuiltinCall(node, Context::TO_STRING_BUILTIN_INDEX, 1); |
| 301 } | 300 } |
| 302 | 301 |
| 303 | 302 |
| 304 void JSGenericLowering::LowerJSToName(Node* node) { | 303 void JSGenericLowering::LowerJSToName(Node* node) { |
| 305 ReplaceWithBuiltinCall(node, Builtins::TO_NAME, 1); | 304 ReplaceWithBuiltinCall(node, Context::TO_NAME_BUILTIN_INDEX, 1); |
| 306 } | 305 } |
| 307 | 306 |
| 308 | 307 |
| 309 void JSGenericLowering::LowerJSToObject(Node* node) { | 308 void JSGenericLowering::LowerJSToObject(Node* node) { |
| 310 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 309 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 311 Callable callable = CodeFactory::ToObject(isolate()); | 310 Callable callable = CodeFactory::ToObject(isolate()); |
| 312 ReplaceWithStubCall(node, callable, flags); | 311 ReplaceWithStubCall(node, callable, flags); |
| 313 } | 312 } |
| 314 | 313 |
| 315 | 314 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 429 |
| 431 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 430 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
| 432 LanguageMode language_mode = OpParameter<LanguageMode>(node); | 431 LanguageMode language_mode = OpParameter<LanguageMode>(node); |
| 433 ReplaceWithRuntimeCall(node, is_strict(language_mode) | 432 ReplaceWithRuntimeCall(node, is_strict(language_mode) |
| 434 ? Runtime::kDeleteProperty_Strict | 433 ? Runtime::kDeleteProperty_Strict |
| 435 : Runtime::kDeleteProperty_Sloppy); | 434 : Runtime::kDeleteProperty_Sloppy); |
| 436 } | 435 } |
| 437 | 436 |
| 438 | 437 |
| 439 void JSGenericLowering::LowerJSHasProperty(Node* node) { | 438 void JSGenericLowering::LowerJSHasProperty(Node* node) { |
| 440 ReplaceWithBuiltinCall(node, Builtins::IN, 2); | 439 ReplaceWithBuiltinCall(node, Context::IN_BUILTIN_INDEX, 2); |
| 441 } | 440 } |
| 442 | 441 |
| 443 | 442 |
| 444 void JSGenericLowering::LowerJSInstanceOf(Node* node) { | 443 void JSGenericLowering::LowerJSInstanceOf(Node* node) { |
| 445 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 444 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 446 Callable callable = CodeFactory::InstanceOf(isolate()); | 445 Callable callable = CodeFactory::InstanceOf(isolate()); |
| 447 ReplaceWithStubCall(node, callable, flags); | 446 ReplaceWithStubCall(node, callable, flags); |
| 448 } | 447 } |
| 449 | 448 |
| 450 | 449 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 } | 845 } |
| 847 | 846 |
| 848 | 847 |
| 849 MachineOperatorBuilder* JSGenericLowering::machine() const { | 848 MachineOperatorBuilder* JSGenericLowering::machine() const { |
| 850 return jsgraph()->machine(); | 849 return jsgraph()->machine(); |
| 851 } | 850 } |
| 852 | 851 |
| 853 } // namespace compiler | 852 } // namespace compiler |
| 854 } // namespace internal | 853 } // namespace internal |
| 855 } // namespace v8 | 854 } // namespace v8 |
| OLD | NEW |