Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/compiler/js-native-context-specialization.cc

Issue 2770003002: Set the current context to the function's context when entering to LAP. (Closed)
Patch Set: Synced. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-native-context-specialization.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/js-native-context-specialization.h" 5 #include "src/compiler/js-native-context-specialization.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 target, frame_state); 1440 target, frame_state);
1441 1441
1442 // Introduce the call to the getter function. 1442 // Introduce the call to the getter function.
1443 Node* value; 1443 Node* value;
1444 if (access_info.constant()->IsJSFunction()) { 1444 if (access_info.constant()->IsJSFunction()) {
1445 value = *effect = *control = graph()->NewNode( 1445 value = *effect = *control = graph()->NewNode(
1446 jsgraph()->javascript()->Call(2, CallFrequency(), VectorSlotPair(), 1446 jsgraph()->javascript()->Call(2, CallFrequency(), VectorSlotPair(),
1447 ConvertReceiverMode::kNotNullOrUndefined), 1447 ConvertReceiverMode::kNotNullOrUndefined),
1448 target, receiver, context, frame_state0, *effect, *control); 1448 target, receiver, context, frame_state0, *effect, *control);
1449 } else { 1449 } else {
1450 Node* holder = jsgraph()->Constant(access_info.holder().ToHandleChecked());
1450 DCHECK(access_info.constant()->IsFunctionTemplateInfo()); 1451 DCHECK(access_info.constant()->IsFunctionTemplateInfo());
1451 Handle<FunctionTemplateInfo> function_template_info( 1452 Handle<FunctionTemplateInfo> function_template_info(
1452 Handle<FunctionTemplateInfo>::cast(access_info.constant())); 1453 Handle<FunctionTemplateInfo>::cast(access_info.constant()));
1453 DCHECK(!function_template_info->call_code()->IsUndefined(isolate())); 1454 DCHECK(!function_template_info->call_code()->IsUndefined(isolate()));
1454 value = InlineApiCall(receiver, context, target, frame_state0, nullptr, 1455 value =
1455 effect, control, shared_info, function_template_info); 1456 InlineApiCall(receiver, holder, context, target, frame_state0, nullptr,
1457 effect, control, shared_info, function_template_info);
1456 } 1458 }
1457 // Remember to rewire the IfException edge if this is inside a try-block. 1459 // Remember to rewire the IfException edge if this is inside a try-block.
1458 if (if_exceptions != nullptr) { 1460 if (if_exceptions != nullptr) {
1459 // Create the appropriate IfException/IfSuccess projections. 1461 // Create the appropriate IfException/IfSuccess projections.
1460 Node* const if_exception = 1462 Node* const if_exception =
1461 graph()->NewNode(common()->IfException(), *control, *effect); 1463 graph()->NewNode(common()->IfException(), *control, *effect);
1462 Node* const if_success = graph()->NewNode(common()->IfSuccess(), *control); 1464 Node* const if_success = graph()->NewNode(common()->IfSuccess(), *control);
1463 if_exceptions->push_back(if_exception); 1465 if_exceptions->push_back(if_exception);
1464 *control = if_success; 1466 *control = if_success;
1465 } 1467 }
(...skipping 21 matching lines...) Expand all
1487 jsgraph()->EmptyStateValues(), jsgraph()->EmptyStateValues(), context, 1489 jsgraph()->EmptyStateValues(), jsgraph()->EmptyStateValues(), context,
1488 target, frame_state); 1490 target, frame_state);
1489 1491
1490 // Introduce the call to the setter function. 1492 // Introduce the call to the setter function.
1491 if (access_info.constant()->IsJSFunction()) { 1493 if (access_info.constant()->IsJSFunction()) {
1492 *effect = *control = graph()->NewNode( 1494 *effect = *control = graph()->NewNode(
1493 jsgraph()->javascript()->Call(3, CallFrequency(), VectorSlotPair(), 1495 jsgraph()->javascript()->Call(3, CallFrequency(), VectorSlotPair(),
1494 ConvertReceiverMode::kNotNullOrUndefined), 1496 ConvertReceiverMode::kNotNullOrUndefined),
1495 target, receiver, value, context, frame_state0, *effect, *control); 1497 target, receiver, value, context, frame_state0, *effect, *control);
1496 } else { 1498 } else {
1499 Node* holder = jsgraph()->Constant(access_info.holder().ToHandleChecked());
1497 DCHECK(access_info.constant()->IsFunctionTemplateInfo()); 1500 DCHECK(access_info.constant()->IsFunctionTemplateInfo());
1498 Handle<FunctionTemplateInfo> function_template_info( 1501 Handle<FunctionTemplateInfo> function_template_info(
1499 Handle<FunctionTemplateInfo>::cast(access_info.constant())); 1502 Handle<FunctionTemplateInfo>::cast(access_info.constant()));
1500 DCHECK(!function_template_info->call_code()->IsUndefined(isolate())); 1503 DCHECK(!function_template_info->call_code()->IsUndefined(isolate()));
1501 value = InlineApiCall(receiver, context, target, frame_state0, value, 1504 value =
1502 effect, control, shared_info, function_template_info); 1505 InlineApiCall(receiver, holder, context, target, frame_state0, value,
1506 effect, control, shared_info, function_template_info);
1503 } 1507 }
1504 // Remember to rewire the IfException edge if this is inside a try-block. 1508 // Remember to rewire the IfException edge if this is inside a try-block.
1505 if (if_exceptions != nullptr) { 1509 if (if_exceptions != nullptr) {
1506 // Create the appropriate IfException/IfSuccess projections. 1510 // Create the appropriate IfException/IfSuccess projections.
1507 Node* const if_exception = 1511 Node* const if_exception =
1508 graph()->NewNode(common()->IfException(), *control, *effect); 1512 graph()->NewNode(common()->IfException(), *control, *effect);
1509 Node* const if_success = graph()->NewNode(common()->IfSuccess(), *control); 1513 Node* const if_success = graph()->NewNode(common()->IfSuccess(), *control);
1510 if_exceptions->push_back(if_exception); 1514 if_exceptions->push_back(if_exception);
1511 *control = if_success; 1515 *control = if_success;
1512 } 1516 }
1513 return value; 1517 return value;
1514 } 1518 }
1515 1519
1516 Node* JSNativeContextSpecialization::InlineApiCall( 1520 Node* JSNativeContextSpecialization::InlineApiCall(
1517 Node* receiver, Node* context, Node* target, Node* frame_state, Node* value, 1521 Node* receiver, Node* holder, Node* context, Node* target,
1518 Node** effect, Node** control, Handle<SharedFunctionInfo> shared_info, 1522 Node* frame_state, Node* value, Node** effect, Node** control,
1523 Handle<SharedFunctionInfo> shared_info,
1519 Handle<FunctionTemplateInfo> function_template_info) { 1524 Handle<FunctionTemplateInfo> function_template_info) {
1520 Handle<CallHandlerInfo> call_handler_info = handle( 1525 Handle<CallHandlerInfo> call_handler_info = handle(
1521 CallHandlerInfo::cast(function_template_info->call_code()), isolate()); 1526 CallHandlerInfo::cast(function_template_info->call_code()), isolate());
1522 Handle<Object> call_data_object(call_handler_info->data(), isolate()); 1527 Handle<Object> call_data_object(call_handler_info->data(), isolate());
1523 1528
1524 // Only setters have a value. 1529 // Only setters have a value.
1525 int const argc = value == nullptr ? 0 : 1; 1530 int const argc = value == nullptr ? 0 : 1;
1526 // The stub always expects the receiver as the first param on the stack. 1531 // The stub always expects the receiver as the first param on the stack.
1527 CallApiCallbackStub stub( 1532 CallApiCallbackStub stub(
1528 isolate(), argc, 1533 isolate(), argc,
1529 true /* FunctionTemplateInfo doesn't have an associated context. */); 1534 true /* FunctionTemplateInfo doesn't have an associated context. */);
1530 CallInterfaceDescriptor call_interface_descriptor = 1535 CallInterfaceDescriptor call_interface_descriptor =
1531 stub.GetCallInterfaceDescriptor(); 1536 stub.GetCallInterfaceDescriptor();
1532 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 1537 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1533 isolate(), graph()->zone(), call_interface_descriptor, 1538 isolate(), graph()->zone(), call_interface_descriptor,
1534 call_interface_descriptor.GetStackParameterCount() + argc + 1539 call_interface_descriptor.GetStackParameterCount() + argc +
1535 1 /* implicit receiver */, 1540 1 /* implicit receiver */ + 1 /* accessor holder */,
1536 CallDescriptor::kNeedsFrameState, Operator::kNoProperties, 1541 CallDescriptor::kNeedsFrameState, Operator::kNoProperties,
1537 MachineType::AnyTagged(), 1); 1542 MachineType::AnyTagged(), 1);
1538 1543
1539 Node* data = jsgraph()->Constant(call_data_object); 1544 Node* data = jsgraph()->Constant(call_data_object);
1540 ApiFunction function(v8::ToCData<Address>(call_handler_info->callback())); 1545 ApiFunction function(v8::ToCData<Address>(call_handler_info->callback()));
1541 Node* function_reference = 1546 Node* function_reference =
1542 graph()->NewNode(common()->ExternalConstant(ExternalReference( 1547 graph()->NewNode(common()->ExternalConstant(ExternalReference(
1543 &function, ExternalReference::DIRECT_API_CALL, isolate()))); 1548 &function, ExternalReference::DIRECT_API_CALL, isolate())));
1544 Node* code = jsgraph()->HeapConstant(stub.GetCode()); 1549 Node* code = jsgraph()->HeapConstant(stub.GetCode());
1545 1550
1546 // Add CallApiCallbackStub's register argument as well. 1551 // Add CallApiCallbackStub's register argument as well.
1547 Node* inputs[11] = { 1552 Node* inputs[12] = {
1548 code, target, data, receiver /* holder */, function_reference, receiver}; 1553 code, target, data, receiver /* holder */, function_reference,
1549 int index = 6 + argc; 1554 holder, receiver};
1555 int index = 7 + argc;
1550 inputs[index++] = context; 1556 inputs[index++] = context;
1551 inputs[index++] = frame_state; 1557 inputs[index++] = frame_state;
1552 inputs[index++] = *effect; 1558 inputs[index++] = *effect;
1553 inputs[index++] = *control; 1559 inputs[index++] = *control;
1554 // This needs to stay here because of the edge case described in 1560 // This needs to stay here because of the edge case described in
1555 // http://crbug.com/675648. 1561 // http://crbug.com/675648.
1556 if (value != nullptr) { 1562 if (value != nullptr) {
1557 inputs[6] = value; 1563 inputs[7] = value;
1558 } 1564 }
1559 1565
1560 return *effect = *control = 1566 return *effect = *control =
1561 graph()->NewNode(common()->Call(call_descriptor), index, inputs); 1567 graph()->NewNode(common()->Call(call_descriptor), index, inputs);
1562 } 1568 }
1563 1569
1564 JSNativeContextSpecialization::ValueEffectControl 1570 JSNativeContextSpecialization::ValueEffectControl
1565 JSNativeContextSpecialization::BuildPropertyLoad( 1571 JSNativeContextSpecialization::BuildPropertyLoad(
1566 Node* receiver, Node* context, Node* frame_state, Node* effect, 1572 Node* receiver, Node* context, Node* frame_state, Node* effect,
1567 Node* control, Handle<Name> name, ZoneVector<Node*>* if_exceptions, 1573 Node* control, Handle<Name> name, ZoneVector<Node*>* if_exceptions,
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 return jsgraph()->javascript(); 2410 return jsgraph()->javascript();
2405 } 2411 }
2406 2412
2407 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { 2413 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const {
2408 return jsgraph()->simplified(); 2414 return jsgraph()->simplified();
2409 } 2415 }
2410 2416
2411 } // namespace compiler 2417 } // namespace compiler
2412 } // namespace internal 2418 } // namespace internal
2413 } // namespace v8 2419 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-native-context-specialization.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698