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

Side by Side Diff: src/hydrogen.cc

Issue 12255033: Fix f.apply() optimization when declared arguments are mutated. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/compiler/inline-function-apply.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 7986 matching lines...) Expand 10 before | Expand all | Expand 10 after
7997 elements); 7997 elements);
7998 result->set_position(expr->position()); 7998 result->set_position(expr->position());
7999 ast_context()->ReturnInstruction(result, expr->id()); 7999 ast_context()->ReturnInstruction(result, expr->id());
8000 return true; 8000 return true;
8001 } else { 8001 } else {
8002 // We are inside inlined function and we know exactly what is inside 8002 // We are inside inlined function and we know exactly what is inside
8003 // arguments object. But we need to be able to materialize at deopt. 8003 // arguments object. But we need to be able to materialize at deopt.
8004 // TODO(mstarzinger): For now we just ensure arguments are pushed 8004 // TODO(mstarzinger): For now we just ensure arguments are pushed
8005 // right after HEnterInlined, but we could be smarter about this. 8005 // right after HEnterInlined, but we could be smarter about this.
8006 EnsureArgumentsArePushedForAccess(); 8006 EnsureArgumentsArePushedForAccess();
8007 HEnvironment* arguments_env = environment()->arguments_environment(); 8007 ASSERT_EQ(environment()->arguments_environment()->parameter_count(),
8008 int parameter_count = arguments_env->parameter_count(); 8008 function_state()->entry()->arguments_values()->length());
8009 HEnterInlined* entry = function_state()->entry();
8010 ZoneList<HValue*>* arguments_values = entry->arguments_values();
8011 int arguments_count = arguments_values->length();
8009 PushAndAdd(new(zone()) HWrapReceiver(receiver, function)); 8012 PushAndAdd(new(zone()) HWrapReceiver(receiver, function));
8010 for (int i = 1; i < arguments_env->parameter_count(); i++) { 8013 for (int i = 1; i < arguments_count; i++) {
8011 Push(arguments_env->Lookup(i)); 8014 Push(arguments_values->at(i));
8012 } 8015 }
8013 8016
8014 Handle<JSFunction> known_function; 8017 Handle<JSFunction> known_function;
8015 if (function->IsConstant()) { 8018 if (function->IsConstant()) {
8016 HConstant* constant_function = HConstant::cast(function); 8019 HConstant* constant_function = HConstant::cast(function);
8017 known_function = Handle<JSFunction>::cast(constant_function->handle()); 8020 known_function = Handle<JSFunction>::cast(constant_function->handle());
8018 int arguments_count = parameter_count - 1; // Excluding receiver. 8021 int args_count = arguments_count - 1; // Excluding receiver.
8019 if (TryInlineApply(known_function, expr, arguments_count)) return true; 8022 if (TryInlineApply(known_function, expr, args_count)) return true;
8020 } 8023 }
8021 8024
8022 Drop(parameter_count - 1); 8025 Drop(arguments_count - 1);
8023 PushAndAdd(new(zone()) HPushArgument(Pop())); 8026 PushAndAdd(new(zone()) HPushArgument(Pop()));
8024 for (int i = 1; i < arguments_env->parameter_count(); i++) { 8027 for (int i = 1; i < arguments_count; i++) {
8025 PushAndAdd(new(zone()) HPushArgument(arguments_env->Lookup(i))); 8028 PushAndAdd(new(zone()) HPushArgument(arguments_values->at(i)));
8026 } 8029 }
8027 8030
8028 HValue* context = environment()->LookupContext(); 8031 HValue* context = environment()->LookupContext();
8029 HInvokeFunction* call = new(zone()) HInvokeFunction( 8032 HInvokeFunction* call = new(zone()) HInvokeFunction(
8030 context, 8033 context,
8031 function, 8034 function,
8032 known_function, 8035 known_function,
8033 parameter_count); 8036 arguments_count);
8034 Drop(parameter_count); 8037 Drop(arguments_count);
8035 call->set_position(expr->position()); 8038 call->set_position(expr->position());
8036 ast_context()->ReturnInstruction(call, expr->id()); 8039 ast_context()->ReturnInstruction(call, expr->id());
8037 return true; 8040 return true;
8038 } 8041 }
8039 } 8042 }
8040 8043
8041 8044
8042 // Checks if all maps in |types| are from the same family, i.e., are elements 8045 // Checks if all maps in |types| are from the same family, i.e., are elements
8043 // transitions of each other. Returns either NULL if they are not from the same 8046 // transitions of each other. Returns either NULL if they are not from the same
8044 // family, or a Map* indicating the map with the first elements kind of the 8047 // family, or a Map* indicating the map with the first elements kind of the
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after
10664 } 10667 }
10665 } 10668 }
10666 10669
10667 #ifdef DEBUG 10670 #ifdef DEBUG
10668 if (graph_ != NULL) graph_->Verify(false); // No full verify. 10671 if (graph_ != NULL) graph_->Verify(false); // No full verify.
10669 if (allocator_ != NULL) allocator_->Verify(); 10672 if (allocator_ != NULL) allocator_->Verify();
10670 #endif 10673 #endif
10671 } 10674 }
10672 10675
10673 } } // namespace v8::internal 10676 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/inline-function-apply.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698