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

Side by Side Diff: src/hydrogen.cc

Issue 346473002: Add missing map check to the optimized version of f.call(...). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add map check for f.apply Created 6 years, 6 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/regress/regress-386034.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/hydrogen.h" 5 #include "src/hydrogen.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 8607 matching lines...) Expand 10 before | Expand all | Expand 10 after
8618 } 8618 }
8619 8619
8620 8620
8621 void HOptimizedGraphBuilder::BuildFunctionApply(Call* expr) { 8621 void HOptimizedGraphBuilder::BuildFunctionApply(Call* expr) {
8622 ZoneList<Expression*>* args = expr->arguments(); 8622 ZoneList<Expression*>* args = expr->arguments();
8623 CHECK_ALIVE(VisitForValue(args->at(0))); 8623 CHECK_ALIVE(VisitForValue(args->at(0)));
8624 HValue* receiver = Pop(); // receiver 8624 HValue* receiver = Pop(); // receiver
8625 HValue* function = Pop(); // f 8625 HValue* function = Pop(); // f
8626 Drop(1); // apply 8626 Drop(1); // apply
8627 8627
8628 Handle<Map> function_map = expr->GetReceiverTypes()->first();
8629 HValue* checked_function = AddCheckMap(function, function_map);
8630
8628 if (function_state()->outer() == NULL) { 8631 if (function_state()->outer() == NULL) {
8629 HInstruction* elements = Add<HArgumentsElements>(false); 8632 HInstruction* elements = Add<HArgumentsElements>(false);
8630 HInstruction* length = Add<HArgumentsLength>(elements); 8633 HInstruction* length = Add<HArgumentsLength>(elements);
8631 HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); 8634 HValue* wrapped_receiver = BuildWrapReceiver(receiver, checked_function);
8632 HInstruction* result = New<HApplyArguments>(function, 8635 HInstruction* result = New<HApplyArguments>(function,
8633 wrapped_receiver, 8636 wrapped_receiver,
8634 length, 8637 length,
8635 elements); 8638 elements);
8636 ast_context()->ReturnInstruction(result, expr->id()); 8639 ast_context()->ReturnInstruction(result, expr->id());
8637 } else { 8640 } else {
8638 // We are inside inlined function and we know exactly what is inside 8641 // We are inside inlined function and we know exactly what is inside
8639 // arguments object. But we need to be able to materialize at deopt. 8642 // arguments object. But we need to be able to materialize at deopt.
8640 ASSERT_EQ(environment()->arguments_environment()->parameter_count(), 8643 ASSERT_EQ(environment()->arguments_environment()->parameter_count(),
8641 function_state()->entry()->arguments_object()->arguments_count()); 8644 function_state()->entry()->arguments_object()->arguments_count());
8642 HArgumentsObject* args = function_state()->entry()->arguments_object(); 8645 HArgumentsObject* args = function_state()->entry()->arguments_object();
8643 const ZoneList<HValue*>* arguments_values = args->arguments_values(); 8646 const ZoneList<HValue*>* arguments_values = args->arguments_values();
8644 int arguments_count = arguments_values->length(); 8647 int arguments_count = arguments_values->length();
8645 Push(function); 8648 Push(function);
8646 Push(BuildWrapReceiver(receiver, function)); 8649 Push(BuildWrapReceiver(receiver, checked_function));
8647 for (int i = 1; i < arguments_count; i++) { 8650 for (int i = 1; i < arguments_count; i++) {
8648 Push(arguments_values->at(i)); 8651 Push(arguments_values->at(i));
8649 } 8652 }
8650 HandleIndirectCall(expr, function, arguments_count); 8653 HandleIndirectCall(expr, function, arguments_count);
8651 } 8654 }
8652 } 8655 }
8653 8656
8654 8657
8655 // f.call(...) 8658 // f.call(...)
8656 void HOptimizedGraphBuilder::BuildFunctionCall(Call* expr) { 8659 void HOptimizedGraphBuilder::BuildFunctionCall(Call* expr) {
8657 HValue* function = Pop(); // f 8660 HValue* function = Pop(); // f
8658 HValue* receiver; 8661 HValue* receiver;
8659 ZoneList<Expression*>* args = expr->arguments(); 8662 ZoneList<Expression*>* args = expr->arguments();
8660 int args_length = args->length(); 8663 int args_length = args->length();
8661 Drop(1); // call 8664 Drop(1); // call
8662 8665
8663 if (args_length == 0) { 8666 if (args_length == 0) {
8664 receiver = graph()->GetConstantUndefined(); 8667 receiver = graph()->GetConstantUndefined();
8665 args_length = 1; 8668 args_length = 1;
8666 } else { 8669 } else {
8667 CHECK_ALIVE(VisitForValue(args->at(0))); 8670 CHECK_ALIVE(VisitForValue(args->at(0)));
8668 receiver = Pop(); 8671 receiver = Pop();
8669 } 8672 }
8670 receiver = BuildWrapReceiver(receiver, function); 8673
8674 Handle<Map> function_map = expr->GetReceiverTypes()->first();
8675 HValue* checked_function = AddCheckMap(function, function_map);
8676
8677 receiver = BuildWrapReceiver(receiver, checked_function);
8671 8678
8672 Push(function); 8679 Push(function);
8673 Push(receiver); 8680 Push(receiver);
8674 for (int i = 1; i < args_length; i++) { 8681 for (int i = 1; i < args_length; i++) {
8675 CHECK_ALIVE(VisitForValue(args->at(i))); 8682 CHECK_ALIVE(VisitForValue(args->at(i)));
8676 } 8683 }
8677 HandleIndirectCall(expr, function, args_length); 8684 HandleIndirectCall(expr, function, args_length);
8678 } 8685 }
8679 8686
8680 8687
(...skipping 3736 matching lines...) Expand 10 before | Expand all | Expand 10 after
12417 if (ShouldProduceTraceOutput()) { 12424 if (ShouldProduceTraceOutput()) {
12418 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 12425 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
12419 } 12426 }
12420 12427
12421 #ifdef DEBUG 12428 #ifdef DEBUG
12422 graph_->Verify(false); // No full verify. 12429 graph_->Verify(false); // No full verify.
12423 #endif 12430 #endif
12424 } 12431 }
12425 12432
12426 } } // namespace v8::internal 12433 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-386034.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698