| 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/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
| 9 #include "src/compiler/js-generic-lowering.h" | 9 #include "src/compiler/js-generic-lowering.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 | 180 |
| 181 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, | 181 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, |
| 182 Builtins::JavaScript id, | 182 Builtins::JavaScript id, |
| 183 int nargs) { | 183 int nargs) { |
| 184 Operator::Properties properties = node->op()->properties(); | 184 Operator::Properties properties = node->op()->properties(); |
| 185 Callable callable = | 185 Callable callable = |
| 186 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | 186 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); |
| 187 CallDescriptor* desc = linkage()->GetStubCallDescriptor( | 187 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 188 callable.descriptor(), nargs, FlagsForNode(node), properties); | 188 callable.descriptor(), nargs, FlagsForNode(node), properties); |
| 189 // TODO(mstarzinger): Accessing the builtins object this way prevents sharing | 189 Node* global_object = graph()->NewNode( |
| 190 // of code across native contexts. Fix this by loading from given context. | 190 machine()->Load(kMachAnyTagged), NodeProperties::GetContextInput(node), |
| 191 Handle<JSFunction> function( | 191 jsgraph()->IntPtrConstant( |
| 192 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); | 192 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)), |
| 193 NodeProperties::GetEffectInput(node), graph()->start()); |
| 194 Node* builtins_object = graph()->NewNode( |
| 195 machine()->Load(kMachAnyTagged), global_object, |
| 196 jsgraph()->IntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag), |
| 197 NodeProperties::GetEffectInput(node), graph()->start()); |
| 198 Node* function = graph()->NewNode( |
| 199 machine()->Load(kMachAnyTagged), builtins_object, |
| 200 jsgraph()->IntPtrConstant(JSBuiltinsObject::OffsetOfFunctionWithId(id) - |
| 201 kHeapObjectTag), |
| 202 NodeProperties::GetEffectInput(node), graph()->start()); |
| 193 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 203 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 194 Node* function_node = jsgraph()->HeapConstant(function); | |
| 195 PatchInsertInput(node, 0, stub_code); | 204 PatchInsertInput(node, 0, stub_code); |
| 196 PatchInsertInput(node, 1, function_node); | 205 PatchInsertInput(node, 1, function); |
| 197 PatchOperator(node, common()->Call(desc)); | 206 PatchOperator(node, common()->Call(desc)); |
| 198 } | 207 } |
| 199 | 208 |
| 200 | 209 |
| 201 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 210 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
| 202 Runtime::FunctionId f, | 211 Runtime::FunctionId f, |
| 203 int nargs_override) { | 212 int nargs_override) { |
| 204 Operator::Properties properties = node->op()->properties(); | 213 Operator::Properties properties = node->op()->properties(); |
| 205 const Runtime::Function* fun = Runtime::FunctionForId(f); | 214 const Runtime::Function* fun = Runtime::FunctionForId(f); |
| 206 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 215 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 void JSGenericLowering::LowerJSStoreNamed(Node* node) { | 293 void JSGenericLowering::LowerJSStoreNamed(Node* node) { |
| 285 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); | 294 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); |
| 286 Callable callable = CodeFactory::StoreIC(isolate(), p.strict_mode()); | 295 Callable callable = CodeFactory::StoreIC(isolate(), p.strict_mode()); |
| 287 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name())); | 296 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name())); |
| 288 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 297 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
| 289 } | 298 } |
| 290 | 299 |
| 291 | 300 |
| 292 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 301 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
| 293 StrictMode strict_mode = OpParameter<StrictMode>(node); | 302 StrictMode strict_mode = OpParameter<StrictMode>(node); |
| 294 PatchInsertInput(node, 2, jsgraph()->SmiConstant(strict_mode)); | |
| 295 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); | 303 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); |
| 304 PatchInsertInput(node, 4, jsgraph()->SmiConstant(strict_mode)); |
| 296 } | 305 } |
| 297 | 306 |
| 298 | 307 |
| 299 void JSGenericLowering::LowerJSHasProperty(Node* node) { | 308 void JSGenericLowering::LowerJSHasProperty(Node* node) { |
| 300 ReplaceWithBuiltinCall(node, Builtins::IN, 2); | 309 ReplaceWithBuiltinCall(node, Builtins::IN, 2); |
| 301 } | 310 } |
| 302 | 311 |
| 303 | 312 |
| 304 void JSGenericLowering::LowerJSInstanceOf(Node* node) { | 313 void JSGenericLowering::LowerJSInstanceOf(Node* node) { |
| 305 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( | 314 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 432 |
| 424 | 433 |
| 425 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 434 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
| 426 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 435 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
| 427 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 436 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
| 428 } | 437 } |
| 429 | 438 |
| 430 } // namespace compiler | 439 } // namespace compiler |
| 431 } // namespace internal | 440 } // namespace internal |
| 432 } // namespace v8 | 441 } // namespace v8 |
| OLD | NEW |