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

Side by Side Diff: src/hydrogen.cc

Issue 5753005: Make closures optimizable by Crankshaft compiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing next round of Florian's comments Created 10 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 2912 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 2923
2924 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { 2924 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
2925 Variable* variable = expr->AsVariable(); 2925 Variable* variable = expr->AsVariable();
2926 if (variable == NULL) { 2926 if (variable == NULL) {
2927 BAILOUT("reference to rewritten variable"); 2927 BAILOUT("reference to rewritten variable");
2928 } else if (variable->IsStackAllocated()) { 2928 } else if (variable->IsStackAllocated()) {
2929 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) { 2929 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) {
2930 BAILOUT("unsupported context for arguments object"); 2930 BAILOUT("unsupported context for arguments object");
2931 } 2931 }
2932 ast_context()->ReturnValue(environment()->Lookup(variable)); 2932 ast_context()->ReturnValue(environment()->Lookup(variable));
2933 } else if (variable->AsSlot() != NULL &&
2934 variable->AsSlot()->type() == Slot::CONTEXT) {
Kevin Millikin (Chromium) 2010/12/20 12:05:44 This predicate (->AsSlot() != NULL && ->AsSlot()->
antonm 2010/12/20 20:39:24 Done. I named IsContextSlot as IMHO IsHeapAllocat
2935 if (variable->mode() == Variable::CONST) {
2936 BAILOUT("reference to const context slot");
2937 }
2938 Slot* slot = variable->AsSlot();
2939 CompilationInfo* info = graph()->info();
2940 int context_chain_length = info->function()->scope()->
2941 ContextChainLength(slot->var()->scope());
2942 ASSERT(context_chain_length >= 0);
2943 // TODO(antonm): if slot's value is not modified by closures, instead
2944 // of reading it out of context, we could just embed the value as
2945 // a constant.
2946 HLoadContextSlot* instr =
2947 new HLoadContextSlot(context_chain_length, slot->index());
2948 ast_context()->ReturnInstruction(instr, expr->id());
2933 } else if (variable->is_global()) { 2949 } else if (variable->is_global()) {
2934 LookupResult lookup; 2950 LookupResult lookup;
2935 LookupGlobalPropertyCell(variable, &lookup, false); 2951 LookupGlobalPropertyCell(variable, &lookup, false);
2936 CHECK_BAILOUT; 2952 CHECK_BAILOUT;
2937 2953
2938 Handle<GlobalObject> global(graph()->info()->global_object()); 2954 Handle<GlobalObject> global(graph()->info()->global_object());
2939 // TODO(3039103): Handle global property load through an IC call when access 2955 // TODO(3039103): Handle global property load through an IC call when access
2940 // checks are enabled. 2956 // checks are enabled.
2941 if (global->IsAccessCheckNeeded()) { 2957 if (global->IsAccessCheckNeeded()) {
2942 BAILOUT("global object requires access check"); 2958 BAILOUT("global object requires access check");
2943 } 2959 }
2944 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); 2960 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup));
2945 bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly(); 2961 bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly();
2946 HLoadGlobal* instr = new HLoadGlobal(cell, check_hole); 2962 HLoadGlobal* instr = new HLoadGlobal(cell, check_hole);
2947 ast_context()->ReturnInstruction(instr, expr->id()); 2963 ast_context()->ReturnInstruction(instr, expr->id());
2948 } else { 2964 } else {
2949 BAILOUT("reference to non-stack-allocated/non-global variable"); 2965 BAILOUT("reference to non-stack-allocated/non-global variable");
Kevin Millikin (Chromium) 2010/12/20 12:05:44 You should probably change this bailout string. A
antonm 2010/12/20 20:39:24 Done. Please check if wording is fine.
2950 } 2966 }
2951 } 2967 }
2952 2968
2953 2969
2954 void HGraphBuilder::VisitLiteral(Literal* expr) { 2970 void HGraphBuilder::VisitLiteral(Literal* expr) {
2955 HConstant* instr = new HConstant(expr->handle(), Representation::Tagged()); 2971 HConstant* instr = new HConstant(expr->handle(), Representation::Tagged());
2956 ast_context()->ReturnInstruction(instr, expr->id()); 2972 ast_context()->ReturnInstruction(instr, expr->id());
2957 } 2973 }
2958 2974
2959 2975
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
3437 3453
3438 if (expr->is_compound()) { 3454 if (expr->is_compound()) {
3439 HandleCompoundAssignment(expr); 3455 HandleCompoundAssignment(expr);
3440 return; 3456 return;
3441 } 3457 }
3442 3458
3443 if (var != NULL) { 3459 if (var != NULL) {
3444 if (proxy->IsArguments()) BAILOUT("assignment to arguments"); 3460 if (proxy->IsArguments()) BAILOUT("assignment to arguments");
3445 3461
3446 // Handle the assignment. 3462 // Handle the assignment.
3463 if (var->AsSlot() != NULL && var->AsSlot()->type() == Slot::CONTEXT) {
Kevin Millikin (Chromium) 2010/12/20 12:05:44 Instead of an early bailout, it would be better if
antonm 2010/12/20 20:39:24 Done.
3464 BAILOUT("context slot assignment");
3465 }
3447 if (var->is_global()) { 3466 if (var->is_global()) {
3448 VISIT_FOR_VALUE(expr->value()); 3467 VISIT_FOR_VALUE(expr->value());
3449 HandleGlobalVariableAssignment(var, 3468 HandleGlobalVariableAssignment(var,
3450 Top(), 3469 Top(),
3451 expr->position(), 3470 expr->position(),
3452 expr->AssignmentId()); 3471 expr->AssignmentId());
3453 } else { 3472 } else {
Kevin Millikin (Chromium) 2010/12/20 12:05:44 Because here we don't want to have Slot::LOOKUP fa
antonm 2010/12/20 20:39:24 Done.
3454 // We allow reference to the arguments object only in assignemtns 3473 // We allow reference to the arguments object only in assignemtns
3455 // to local variables to make sure that the arguments object does 3474 // to local variables to make sure that the arguments object does
3456 // not escape and is not modified. 3475 // not escape and is not modified.
3457 VariableProxy* rhs = expr->value()->AsVariableProxy(); 3476 VariableProxy* rhs = expr->value()->AsVariableProxy();
3458 if (rhs != NULL && 3477 if (rhs != NULL &&
3459 rhs->var()->IsStackAllocated() && 3478 rhs->var()->IsStackAllocated() &&
3460 environment()->Lookup(rhs->var())->CheckFlag(HValue::kIsArguments)) { 3479 environment()->Lookup(rhs->var())->CheckFlag(HValue::kIsArguments)) {
3461 Push(environment()->Lookup(rhs->var())); 3480 Push(environment()->Lookup(rhs->var()));
3462 } else { 3481 } else {
3463 VISIT_FOR_VALUE(expr->value()); 3482 VISIT_FOR_VALUE(expr->value());
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5671 } 5690 }
5672 5691
5673 #ifdef DEBUG 5692 #ifdef DEBUG
5674 if (graph_ != NULL) graph_->Verify(); 5693 if (graph_ != NULL) graph_->Verify();
5675 if (chunk_ != NULL) chunk_->Verify(); 5694 if (chunk_ != NULL) chunk_->Verify();
5676 if (allocator_ != NULL) allocator_->Verify(); 5695 if (allocator_ != NULL) allocator_->Verify();
5677 #endif 5696 #endif
5678 } 5697 }
5679 5698
5680 } } // namespace v8::internal 5699 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698