Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 176dd9fa77a04f8c401cef6fd8da191bd736cefa..ac63cbd8328310396aafdad9be5c45203ef384f3 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -7730,13 +7730,13 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { |
HValue* function = Pop(); |
Add<HCheckValue>(function, expr->target()); |
- // Replace the global object with the global receiver. |
- HGlobalReceiver* global_receiver = Add<HGlobalReceiver>(global_object); |
- // Index of the receiver from the top of the expression stack. |
+ // Install global receiver on stack. |
+ Handle<JSObject> global_receiver( |
+ expr->target()->context()->global_object()->global_receiver()); |
Toon Verwaest
2013/12/18 13:09:33
context()->global_proxy()
Weren't you planning on
|
const int receiver_index = argument_count - 1; |
- ASSERT(environment()->ExpressionStackAt(receiver_index)-> |
- IsGlobalObject()); |
- environment()->SetExpressionStackAt(receiver_index, global_receiver); |
+ HConstant* global_receiver_constant = Add<HConstant>(global_receiver); |
+ environment()->SetExpressionStackAt( |
+ receiver_index, global_receiver_constant); |
if (TryInlineBuiltinFunctionCall(expr, false)) { // Nothing to drop. |
if (FLAG_trace_inlining) { |
@@ -7753,9 +7753,12 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { |
} |
if (CallStubCompiler::HasCustomCallGenerator(expr->target())) { |
+ // We're about to install a contextual IC, which expects the global |
+ // object as receiver rather than the global proxy. |
+ environment()->SetExpressionStackAt(receiver_index, global_object); |
// When the target has a custom call IC generator, use the IC, |
// because it is likely to generate better code. |
- call = PreProcessCall(New<HCallNamed>(var->name(), argument_count)); |
+ call = PreProcessCall(New<HCallGlobal>(var->name(), argument_count)); |
} else { |
call = PreProcessCall(New<HCallKnownGlobal>( |
expr->target(), argument_count)); |
@@ -7774,11 +7777,16 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { |
// evaluation of the arguments. |
CHECK_ALIVE(VisitForValue(expr->expression())); |
HValue* function = Top(); |
- HGlobalObject* global = Add<HGlobalObject>(); |
- HGlobalReceiver* receiver = Add<HGlobalReceiver>(global); |
- Push(receiver); |
+ Push(graph()->GetConstantUndefined()); |
CHECK_ALIVE(VisitExpressions(expr->arguments())); |
Add<HCheckValue>(function, expr->target()); |
+ // Install global receiver on stack. |
+ Handle<JSObject> global_receiver( |
+ expr->target()->context()->global_object()->global_receiver()); |
+ const int receiver_index = argument_count - 1; |
+ HConstant* global_receiver_constant = Add<HConstant>(global_receiver); |
+ environment()->SetExpressionStackAt( |
+ receiver_index, global_receiver_constant); |
if (TryInlineBuiltinFunctionCall(expr, true)) { // Drop the function. |
if (FLAG_trace_inlining) { |
@@ -7800,12 +7808,11 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) { |
} else { |
CHECK_ALIVE(VisitForValue(expr->expression())); |
HValue* function = Top(); |
- HGlobalObject* global_object = Add<HGlobalObject>(); |
- HGlobalReceiver* receiver = Add<HGlobalReceiver>(global_object); |
+ HValue* receiver = graph()->GetConstantHole(); |
Push(Add<HPushArgument>(receiver)); |
CHECK_ALIVE(VisitArgumentList(expr->arguments())); |
- |
- call = New<HCallFunction>(function, argument_count); |
+ call = New<HCallFunction>( |
+ function, argument_count, NORMAL_CONTEXTUAL_CALL); |
Drop(argument_count + 1); |
} |
} |