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

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: Next round Created 9 years, 11 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 | « src/flag-definitions.h ('k') | src/hydrogen-instructions.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 2933
2934 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { 2934 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
2935 Variable* variable = expr->AsVariable(); 2935 Variable* variable = expr->AsVariable();
2936 if (variable == NULL) { 2936 if (variable == NULL) {
2937 BAILOUT("reference to rewritten variable"); 2937 BAILOUT("reference to rewritten variable");
2938 } else if (variable->IsStackAllocated()) { 2938 } else if (variable->IsStackAllocated()) {
2939 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) { 2939 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) {
2940 BAILOUT("unsupported context for arguments object"); 2940 BAILOUT("unsupported context for arguments object");
2941 } 2941 }
2942 ast_context()->ReturnValue(environment()->Lookup(variable)); 2942 ast_context()->ReturnValue(environment()->Lookup(variable));
2943 } else if (variable->IsContextSlot()) {
2944 if (variable->mode() == Variable::CONST) {
2945 BAILOUT("reference to const context slot");
2946 }
2947 Slot* slot = variable->AsSlot();
2948 CompilationInfo* info = graph()->info();
2949 int context_chain_length = info->function()->scope()->
2950 ContextChainLength(slot->var()->scope());
2951 ASSERT(context_chain_length >= 0);
2952 // TODO(antonm): if slot's value is not modified by closures, instead
2953 // of reading it out of context, we could just embed the value as
2954 // a constant.
2955 HLoadContextSlot* instr =
2956 new HLoadContextSlot(context_chain_length, slot->index());
2957 ast_context()->ReturnInstruction(instr, expr->id());
2943 } else if (variable->is_global()) { 2958 } else if (variable->is_global()) {
2944 LookupResult lookup; 2959 LookupResult lookup;
2945 LookupGlobalPropertyCell(variable, &lookup, false); 2960 LookupGlobalPropertyCell(variable, &lookup, false);
2946 CHECK_BAILOUT; 2961 CHECK_BAILOUT;
2947 2962
2948 Handle<GlobalObject> global(graph()->info()->global_object()); 2963 Handle<GlobalObject> global(graph()->info()->global_object());
2949 // TODO(3039103): Handle global property load through an IC call when access 2964 // TODO(3039103): Handle global property load through an IC call when access
2950 // checks are enabled. 2965 // checks are enabled.
2951 if (global->IsAccessCheckNeeded()) { 2966 if (global->IsAccessCheckNeeded()) {
2952 BAILOUT("global object requires access check"); 2967 BAILOUT("global object requires access check");
2953 } 2968 }
2954 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); 2969 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup));
2955 bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly(); 2970 bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly();
2956 HLoadGlobal* instr = new HLoadGlobal(cell, check_hole); 2971 HLoadGlobal* instr = new HLoadGlobal(cell, check_hole);
2957 ast_context()->ReturnInstruction(instr, expr->id()); 2972 ast_context()->ReturnInstruction(instr, expr->id());
2958 } else { 2973 } else {
2959 BAILOUT("reference to non-stack-allocated/non-global variable"); 2974 BAILOUT("reference to a variable which requires dynamic lookup");
2960 } 2975 }
2961 } 2976 }
2962 2977
2963 2978
2964 void HGraphBuilder::VisitLiteral(Literal* expr) { 2979 void HGraphBuilder::VisitLiteral(Literal* expr) {
2965 HConstant* instr = new HConstant(expr->handle(), Representation::Tagged()); 2980 HConstant* instr = new HConstant(expr->handle(), Representation::Tagged());
2966 ast_context()->ReturnInstruction(instr, expr->id()); 2981 ast_context()->ReturnInstruction(instr, expr->id());
2967 } 2982 }
2968 2983
2969 2984
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 if (var != NULL) { 3490 if (var != NULL) {
3476 if (proxy->IsArguments()) BAILOUT("assignment to arguments"); 3491 if (proxy->IsArguments()) BAILOUT("assignment to arguments");
3477 3492
3478 // Handle the assignment. 3493 // Handle the assignment.
3479 if (var->is_global()) { 3494 if (var->is_global()) {
3480 VISIT_FOR_VALUE(expr->value()); 3495 VISIT_FOR_VALUE(expr->value());
3481 HandleGlobalVariableAssignment(var, 3496 HandleGlobalVariableAssignment(var,
3482 Top(), 3497 Top(),
3483 expr->position(), 3498 expr->position(),
3484 expr->AssignmentId()); 3499 expr->AssignmentId());
3485 } else { 3500 } else if (var->IsStackAllocated()) {
3486 // We allow reference to the arguments object only in assignemtns 3501 // We allow reference to the arguments object only in assignemtns
3487 // to local variables to make sure that the arguments object does 3502 // to local variables to make sure that the arguments object does
3488 // not escape and is not modified. 3503 // not escape and is not modified.
3489 VariableProxy* rhs = expr->value()->AsVariableProxy(); 3504 VariableProxy* rhs = expr->value()->AsVariableProxy();
3490 if (rhs != NULL && 3505 if (rhs != NULL &&
3491 rhs->var()->IsStackAllocated() && 3506 rhs->var()->IsStackAllocated() &&
3492 environment()->Lookup(rhs->var())->CheckFlag(HValue::kIsArguments)) { 3507 environment()->Lookup(rhs->var())->CheckFlag(HValue::kIsArguments)) {
3493 Push(environment()->Lookup(rhs->var())); 3508 Push(environment()->Lookup(rhs->var()));
3494 } else { 3509 } else {
3495 VISIT_FOR_VALUE(expr->value()); 3510 VISIT_FOR_VALUE(expr->value());
3496 } 3511 }
3497 Bind(proxy->var(), Top()); 3512 Bind(proxy->var(), Top());
3513 } else {
3514 BAILOUT("Assigning to no non-stack-allocated/non-global variable");
3498 } 3515 }
3499 // Return the value. 3516 // Return the value.
3500 ast_context()->ReturnValue(Pop()); 3517 ast_context()->ReturnValue(Pop());
3501 3518
3502 } else if (prop != NULL) { 3519 } else if (prop != NULL) {
3503 HandlePropertyAssignment(expr); 3520 HandlePropertyAssignment(expr);
3504 } else { 3521 } else {
3505 BAILOUT("unsupported invalid lhs"); 3522 BAILOUT("unsupported invalid lhs");
3506 } 3523 }
3507 } 3524 }
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
5790 } 5807 }
5791 } 5808 }
5792 5809
5793 #ifdef DEBUG 5810 #ifdef DEBUG
5794 if (graph_ != NULL) graph_->Verify(); 5811 if (graph_ != NULL) graph_->Verify();
5795 if (allocator_ != NULL) allocator_->Verify(); 5812 if (allocator_ != NULL) allocator_->Verify();
5796 #endif 5813 #endif
5797 } 5814 }
5798 5815
5799 } } // namespace v8::internal 5816 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698