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

Side by Side Diff: src/hydrogen.cc

Issue 111613003: Load the global proxy from the context of the target function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: hydrogen Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7712 matching lines...) Expand 10 before | Expand all | Expand 10 after
7723 // Push the global object instead of the global receiver because 7723 // Push the global object instead of the global receiver because
7724 // code generated by the full code generator expects it. 7724 // code generated by the full code generator expects it.
7725 HGlobalObject* global_object = Add<HGlobalObject>(); 7725 HGlobalObject* global_object = Add<HGlobalObject>();
7726 Push(global_object); 7726 Push(global_object);
7727 CHECK_ALIVE(VisitExpressions(expr->arguments())); 7727 CHECK_ALIVE(VisitExpressions(expr->arguments()));
7728 7728
7729 CHECK_ALIVE(VisitForValue(expr->expression())); 7729 CHECK_ALIVE(VisitForValue(expr->expression()));
7730 HValue* function = Pop(); 7730 HValue* function = Pop();
7731 Add<HCheckValue>(function, expr->target()); 7731 Add<HCheckValue>(function, expr->target());
7732 7732
7733 // Replace the global object with the global receiver. 7733 // Install global receiver on stack.
7734 HGlobalReceiver* global_receiver = Add<HGlobalReceiver>(global_object); 7734 Handle<JSObject> global_receiver(
7735 // Index of the receiver from the top of the expression stack. 7735 expr->target()->context()->global_object()->global_receiver());
Toon Verwaest 2013/12/18 13:09:33 context()->global_proxy() Weren't you planning on
7736 const int receiver_index = argument_count - 1; 7736 const int receiver_index = argument_count - 1;
7737 ASSERT(environment()->ExpressionStackAt(receiver_index)-> 7737 HConstant* global_receiver_constant = Add<HConstant>(global_receiver);
7738 IsGlobalObject()); 7738 environment()->SetExpressionStackAt(
7739 environment()->SetExpressionStackAt(receiver_index, global_receiver); 7739 receiver_index, global_receiver_constant);
7740 7740
7741 if (TryInlineBuiltinFunctionCall(expr, false)) { // Nothing to drop. 7741 if (TryInlineBuiltinFunctionCall(expr, false)) { // Nothing to drop.
7742 if (FLAG_trace_inlining) { 7742 if (FLAG_trace_inlining) {
7743 PrintF("Inlining builtin "); 7743 PrintF("Inlining builtin ");
7744 expr->target()->ShortPrint(); 7744 expr->target()->ShortPrint();
7745 PrintF("\n"); 7745 PrintF("\n");
7746 } 7746 }
7747 return; 7747 return;
7748 } 7748 }
7749 if (TryInlineCall(expr)) return; 7749 if (TryInlineCall(expr)) return;
7750 7750
7751 if (expr->target().is_identical_to(current_info()->closure())) { 7751 if (expr->target().is_identical_to(current_info()->closure())) {
7752 graph()->MarkRecursive(); 7752 graph()->MarkRecursive();
7753 } 7753 }
7754 7754
7755 if (CallStubCompiler::HasCustomCallGenerator(expr->target())) { 7755 if (CallStubCompiler::HasCustomCallGenerator(expr->target())) {
7756 // We're about to install a contextual IC, which expects the global
7757 // object as receiver rather than the global proxy.
7758 environment()->SetExpressionStackAt(receiver_index, global_object);
7756 // When the target has a custom call IC generator, use the IC, 7759 // When the target has a custom call IC generator, use the IC,
7757 // because it is likely to generate better code. 7760 // because it is likely to generate better code.
7758 call = PreProcessCall(New<HCallNamed>(var->name(), argument_count)); 7761 call = PreProcessCall(New<HCallGlobal>(var->name(), argument_count));
7759 } else { 7762 } else {
7760 call = PreProcessCall(New<HCallKnownGlobal>( 7763 call = PreProcessCall(New<HCallKnownGlobal>(
7761 expr->target(), argument_count)); 7764 expr->target(), argument_count));
7762 } 7765 }
7763 } else { 7766 } else {
7764 HGlobalObject* receiver = Add<HGlobalObject>(); 7767 HGlobalObject* receiver = Add<HGlobalObject>();
7765 Push(Add<HPushArgument>(receiver)); 7768 Push(Add<HPushArgument>(receiver));
7766 CHECK_ALIVE(VisitArgumentList(expr->arguments())); 7769 CHECK_ALIVE(VisitArgumentList(expr->arguments()));
7767 7770
7768 call = New<HCallGlobal>(var->name(), argument_count); 7771 call = New<HCallGlobal>(var->name(), argument_count);
7769 Drop(argument_count); 7772 Drop(argument_count);
7770 } 7773 }
7771 7774
7772 } else if (expr->IsMonomorphic()) { 7775 } else if (expr->IsMonomorphic()) {
7773 // The function is on the stack in the unoptimized code during 7776 // The function is on the stack in the unoptimized code during
7774 // evaluation of the arguments. 7777 // evaluation of the arguments.
7775 CHECK_ALIVE(VisitForValue(expr->expression())); 7778 CHECK_ALIVE(VisitForValue(expr->expression()));
7776 HValue* function = Top(); 7779 HValue* function = Top();
7777 HGlobalObject* global = Add<HGlobalObject>(); 7780 Push(graph()->GetConstantUndefined());
7778 HGlobalReceiver* receiver = Add<HGlobalReceiver>(global);
7779 Push(receiver);
7780 CHECK_ALIVE(VisitExpressions(expr->arguments())); 7781 CHECK_ALIVE(VisitExpressions(expr->arguments()));
7781 Add<HCheckValue>(function, expr->target()); 7782 Add<HCheckValue>(function, expr->target());
7783 // Install global receiver on stack.
7784 Handle<JSObject> global_receiver(
7785 expr->target()->context()->global_object()->global_receiver());
7786 const int receiver_index = argument_count - 1;
7787 HConstant* global_receiver_constant = Add<HConstant>(global_receiver);
7788 environment()->SetExpressionStackAt(
7789 receiver_index, global_receiver_constant);
7782 7790
7783 if (TryInlineBuiltinFunctionCall(expr, true)) { // Drop the function. 7791 if (TryInlineBuiltinFunctionCall(expr, true)) { // Drop the function.
7784 if (FLAG_trace_inlining) { 7792 if (FLAG_trace_inlining) {
7785 PrintF("Inlining builtin "); 7793 PrintF("Inlining builtin ");
7786 expr->target()->ShortPrint(); 7794 expr->target()->ShortPrint();
7787 PrintF("\n"); 7795 PrintF("\n");
7788 } 7796 }
7789 return; 7797 return;
7790 } 7798 }
7791 7799
7792 if (TryInlineCall(expr, true)) { // Drop function from environment. 7800 if (TryInlineCall(expr, true)) { // Drop function from environment.
7793 return; 7801 return;
7794 } else { 7802 } else {
7795 call = PreProcessCall(New<HInvokeFunction>(function, expr->target(), 7803 call = PreProcessCall(New<HInvokeFunction>(function, expr->target(),
7796 argument_count)); 7804 argument_count));
7797 Drop(1); // The function. 7805 Drop(1); // The function.
7798 } 7806 }
7799 7807
7800 } else { 7808 } else {
7801 CHECK_ALIVE(VisitForValue(expr->expression())); 7809 CHECK_ALIVE(VisitForValue(expr->expression()));
7802 HValue* function = Top(); 7810 HValue* function = Top();
7803 HGlobalObject* global_object = Add<HGlobalObject>(); 7811 HValue* receiver = graph()->GetConstantHole();
7804 HGlobalReceiver* receiver = Add<HGlobalReceiver>(global_object);
7805 Push(Add<HPushArgument>(receiver)); 7812 Push(Add<HPushArgument>(receiver));
7806 CHECK_ALIVE(VisitArgumentList(expr->arguments())); 7813 CHECK_ALIVE(VisitArgumentList(expr->arguments()));
7807 7814 call = New<HCallFunction>(
7808 call = New<HCallFunction>(function, argument_count); 7815 function, argument_count, NORMAL_CONTEXTUAL_CALL);
7809 Drop(argument_count + 1); 7816 Drop(argument_count + 1);
7810 } 7817 }
7811 } 7818 }
7812 7819
7813 return ast_context()->ReturnInstruction(call, expr->id()); 7820 return ast_context()->ReturnInstruction(call, expr->id());
7814 } 7821 }
7815 7822
7816 7823
7817 void HOptimizedGraphBuilder::BuildInlinedCallNewArray(CallNew* expr) { 7824 void HOptimizedGraphBuilder::BuildInlinedCallNewArray(CallNew* expr) {
7818 NoObservableSideEffectsScope no_effects(this); 7825 NoObservableSideEffectsScope no_effects(this);
(...skipping 2994 matching lines...) Expand 10 before | Expand all | Expand 10 after
10813 if (ShouldProduceTraceOutput()) { 10820 if (ShouldProduceTraceOutput()) {
10814 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10821 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10815 } 10822 }
10816 10823
10817 #ifdef DEBUG 10824 #ifdef DEBUG
10818 graph_->Verify(false); // No full verify. 10825 graph_->Verify(false); // No full verify.
10819 #endif 10826 #endif
10820 } 10827 }
10821 10828
10822 } } // namespace v8::internal 10829 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698