| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 HydrogenCodeStub* stub) { | 332 HydrogenCodeStub* stub) { |
| 333 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor(); | 333 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor(); |
| 334 CallDescriptor* desc = linkage()->GetStubCallDescriptor( | 334 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 335 d, 0, DeoptimizationSupportForNode(node)); | 335 d, 0, DeoptimizationSupportForNode(node)); |
| 336 Node* stub_code = CodeConstant(stub->GetCode()); | 336 Node* stub_code = CodeConstant(stub->GetCode()); |
| 337 PatchInsertInput(node, 0, stub_code); | 337 PatchInsertInput(node, 0, stub_code); |
| 338 PatchOperator(node, common()->Call(desc)); | 338 PatchOperator(node, common()->Call(desc)); |
| 339 } | 339 } |
| 340 | 340 |
| 341 | 341 |
| 342 Node* JSGenericLowering::LoadObjectField(Node* object, int offset, |
| 343 Node* effect) { |
| 344 MachineOperatorBuilder machine(jsgraph()->zone()); |
| 345 Node* field_load = jsgraph()->graph()->NewNode( |
| 346 machine.Load(kMachAnyTagged), object, |
| 347 jsgraph()->Int32Constant(offset - kHeapObjectTag), effect); |
| 348 return field_load; |
| 349 } |
| 350 |
| 351 |
| 342 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, | 352 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, |
| 343 Builtins::JavaScript id, | 353 Builtins::JavaScript id, |
| 344 int nargs) { | 354 int nargs) { |
| 345 CallFunctionStub stub(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | 355 CallFunctionStub stub(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); |
| 346 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); | 356 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); |
| 347 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, nargs); | 357 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, nargs); |
| 348 // TODO(mstarzinger): Accessing the builtins object this way prevents sharing | |
| 349 // of code across native contexts. Fix this by loading from given context. | |
| 350 Handle<JSFunction> function( | |
| 351 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); | |
| 352 Node* stub_code = CodeConstant(stub.GetCode()); | 358 Node* stub_code = CodeConstant(stub.GetCode()); |
| 353 Node* function_node = FunctionConstant(function); | 359 Node* function_node = NULL; |
| 360 if (info()->is_context_specializing()) { |
| 361 Handle<JSFunction> function(JSFunction::cast( |
| 362 info()->context()->builtins()->javascript_builtin(id))); |
| 363 function_node = FunctionConstant(function); |
| 364 } else { |
| 365 Node* context = NodeProperties::GetContextInput(node); |
| 366 Node* effect = NodeProperties::GetEffectInput(node); |
| 367 Node* global = LoadObjectField( |
| 368 context, |
| 369 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX) + kHeapObjectTag, |
| 370 effect); |
| 371 Node* builtins = |
| 372 LoadObjectField(global, JSGlobalObject::kBuiltinsOffset, effect); |
| 373 function_node = LoadObjectField( |
| 374 builtins, JSBuiltinsObject::OffsetOfFunctionWithId(id), effect); |
| 375 NodeProperties::ReplaceEffectInput(node, function_node); |
| 376 } |
| 354 PatchInsertInput(node, 0, stub_code); | 377 PatchInsertInput(node, 0, stub_code); |
| 355 PatchInsertInput(node, 1, function_node); | 378 PatchInsertInput(node, 1, function_node); |
| 356 PatchOperator(node, common()->Call(desc)); | 379 PatchOperator(node, common()->Call(desc)); |
| 357 } | 380 } |
| 358 | 381 |
| 359 | 382 |
| 360 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 383 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
| 361 Runtime::FunctionId f, | 384 Runtime::FunctionId f, |
| 362 int nargs_override) { | 385 int nargs_override) { |
| 363 Operator::Property props = node->op()->properties(); | 386 Operator::Property props = node->op()->properties(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 StrictMode strict_mode = info()->strict_mode(); | 461 StrictMode strict_mode = info()->strict_mode(); |
| 439 StoreICStubShim stub(isolate(), strict_mode); | 462 StoreICStubShim stub(isolate(), strict_mode); |
| 440 PatchInsertInput(node, 1, jsgraph()->HeapConstant(key)); | 463 PatchInsertInput(node, 1, jsgraph()->HeapConstant(key)); |
| 441 ReplaceWithICStubCall(node, &stub); | 464 ReplaceWithICStubCall(node, &stub); |
| 442 return node; | 465 return node; |
| 443 } | 466 } |
| 444 | 467 |
| 445 | 468 |
| 446 Node* JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 469 Node* JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
| 447 StrictMode strict_mode = OpParameter<StrictMode>(node); | 470 StrictMode strict_mode = OpParameter<StrictMode>(node); |
| 448 PatchInsertInput(node, 2, SmiConstant(strict_mode)); | |
| 449 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); | 471 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); |
| 472 PatchInsertInput(node, 4, SmiConstant(strict_mode)); |
| 450 return node; | 473 return node; |
| 451 } | 474 } |
| 452 | 475 |
| 453 | 476 |
| 454 Node* JSGenericLowering::LowerJSHasProperty(Node* node) { | 477 Node* JSGenericLowering::LowerJSHasProperty(Node* node) { |
| 455 ReplaceWithBuiltinCall(node, Builtins::IN, 2); | 478 ReplaceWithBuiltinCall(node, Builtins::IN, 2); |
| 456 return node; | 479 return node; |
| 457 } | 480 } |
| 458 | 481 |
| 459 | 482 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 563 |
| 541 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { | 564 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { |
| 542 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); | 565 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); |
| 543 int arity = OperatorProperties::GetValueInputCount(node->op()); | 566 int arity = OperatorProperties::GetValueInputCount(node->op()); |
| 544 ReplaceWithRuntimeCall(node, function, arity); | 567 ReplaceWithRuntimeCall(node, function, arity); |
| 545 return node; | 568 return node; |
| 546 } | 569 } |
| 547 } | 570 } |
| 548 } | 571 } |
| 549 } // namespace v8::internal::compiler | 572 } // namespace v8::internal::compiler |
| OLD | NEW |