| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 CallDescriptor::Flags flags) { | 216 CallDescriptor::Flags flags) { |
| 217 Operator::Properties properties = node->op()->properties(); | 217 Operator::Properties properties = node->op()->properties(); |
| 218 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 218 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 219 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 219 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
| 220 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 220 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 221 node->InsertInput(zone(), 0, stub_code); | 221 node->InsertInput(zone(), 0, stub_code); |
| 222 node->set_op(common()->Call(desc)); | 222 node->set_op(common()->Call(desc)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 | 225 |
| 226 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, int context_index, | |
| 227 int nargs) { | |
| 228 Node* context_input = NodeProperties::GetContextInput(node); | |
| 229 Node* effect_input = NodeProperties::GetEffectInput(node); | |
| 230 | |
| 231 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | |
| 232 Operator::Properties properties = node->op()->properties(); | |
| 233 Callable callable = | |
| 234 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | |
| 235 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | |
| 236 isolate(), zone(), callable.descriptor(), nargs, flags, properties); | |
| 237 Node* global_object = | |
| 238 graph()->NewNode(machine()->Load(kMachAnyTagged), context_input, | |
| 239 jsgraph()->IntPtrConstant( | |
| 240 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)), | |
| 241 effect_input, graph()->start()); | |
| 242 Node* native_context = | |
| 243 graph()->NewNode(machine()->Load(kMachAnyTagged), global_object, | |
| 244 jsgraph()->IntPtrConstant( | |
| 245 GlobalObject::kNativeContextOffset - kHeapObjectTag), | |
| 246 effect_input, graph()->start()); | |
| 247 Node* function = graph()->NewNode( | |
| 248 machine()->Load(kMachAnyTagged), native_context, | |
| 249 jsgraph()->IntPtrConstant(Context::SlotOffset(context_index)), | |
| 250 effect_input, graph()->start()); | |
| 251 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | |
| 252 node->InsertInput(zone(), 0, stub_code); | |
| 253 node->InsertInput(zone(), 1, function); | |
| 254 node->set_op(common()->Call(desc)); | |
| 255 } | |
| 256 | |
| 257 | |
| 258 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 226 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
| 259 Runtime::FunctionId f, | 227 Runtime::FunctionId f, |
| 260 int nargs_override) { | 228 int nargs_override) { |
| 261 Operator::Properties properties = node->op()->properties(); | 229 Operator::Properties properties = node->op()->properties(); |
| 262 const Runtime::Function* fun = Runtime::FunctionForId(f); | 230 const Runtime::Function* fun = Runtime::FunctionForId(f); |
| 263 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 231 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
| 264 CallDescriptor* desc = | 232 CallDescriptor* desc = |
| 265 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties); | 233 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties); |
| 266 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); | 234 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); |
| 267 Node* arity = jsgraph()->Int32Constant(nargs); | 235 Node* arity = jsgraph()->Int32Constant(nargs); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 408 |
| 441 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 409 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
| 442 LanguageMode language_mode = OpParameter<LanguageMode>(node); | 410 LanguageMode language_mode = OpParameter<LanguageMode>(node); |
| 443 ReplaceWithRuntimeCall(node, is_strict(language_mode) | 411 ReplaceWithRuntimeCall(node, is_strict(language_mode) |
| 444 ? Runtime::kDeleteProperty_Strict | 412 ? Runtime::kDeleteProperty_Strict |
| 445 : Runtime::kDeleteProperty_Sloppy); | 413 : Runtime::kDeleteProperty_Sloppy); |
| 446 } | 414 } |
| 447 | 415 |
| 448 | 416 |
| 449 void JSGenericLowering::LowerJSHasProperty(Node* node) { | 417 void JSGenericLowering::LowerJSHasProperty(Node* node) { |
| 450 ReplaceWithBuiltinCall(node, Context::IN_BUILTIN_INDEX, 2); | 418 ReplaceWithRuntimeCall(node, Runtime::kHasProperty); |
| 451 } | 419 } |
| 452 | 420 |
| 453 | 421 |
| 454 void JSGenericLowering::LowerJSInstanceOf(Node* node) { | 422 void JSGenericLowering::LowerJSInstanceOf(Node* node) { |
| 455 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 423 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 456 Callable callable = CodeFactory::InstanceOf(isolate()); | 424 Callable callable = CodeFactory::InstanceOf(isolate()); |
| 457 ReplaceWithStubCall(node, callable, flags); | 425 ReplaceWithStubCall(node, callable, flags); |
| 458 } | 426 } |
| 459 | 427 |
| 460 | 428 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 } | 824 } |
| 857 | 825 |
| 858 | 826 |
| 859 MachineOperatorBuilder* JSGenericLowering::machine() const { | 827 MachineOperatorBuilder* JSGenericLowering::machine() const { |
| 860 return jsgraph()->machine(); | 828 return jsgraph()->machine(); |
| 861 } | 829 } |
| 862 | 830 |
| 863 } // namespace compiler | 831 } // namespace compiler |
| 864 } // namespace internal | 832 } // namespace internal |
| 865 } // namespace v8 | 833 } // namespace v8 |
| OLD | NEW |