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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 153bd9aae9cb02a5121a45ce991363a50f109f94..3f23ef0a96df8ecf920cdd2fb415c498774a3971 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -2930,6 +2930,27 @@ void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
BAILOUT("unsupported context for arguments object");
}
ast_context()->ReturnValue(environment()->Lookup(variable));
+ } else if (variable->AsSlot() != NULL &&
+ variable->AsSlot()->type() == Slot::CONTEXT) {
fschneider 2010/12/13 19:00:18 Indentation.
antonm 2010/12/13 22:41:04 Done.
+ if (variable->mode() == Variable::CONST) {
+ BAILOUT("reference to const context slot");
+ }
+ Slot* slot = variable->AsSlot();
+ CompilationInfo* info = graph()->info();
+ int context_chain_length = info->function()->scope()->
+ ContextChainLength(slot->var()->scope());
+ ASSERT(context_chain_length >= 0);
+ Handle<JSFunction> closure = info->closure();
+ Context* context = closure->context();
+ for (int i = 0; i < context_chain_length; i++) {
+ context = context->closure()->context();
+ }
+ // TODO(antonm): if slot's value is not modified by closures, instead
+ // of reading it out of context, we could just embed the value as
+ // a constant.
+ HLoadContextSlot* instr =
+ new HLoadContextSlot(Handle<Context>(context), slot->index());
+ ast_context()->ReturnInstruction(instr, expr->id());
} else if (variable->is_global()) {
LookupResult lookup;
LookupGlobalPropertyCell(variable, &lookup, false);
@@ -3441,6 +3462,9 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
if (proxy->IsArguments()) BAILOUT("assignment to arguments");
// Handle the assignment.
+ if (var->AsSlot() != NULL && var->AsSlot()->type() == Slot::CONTEXT) {
+ BAILOUT("context slot assignment");
+ }
if (var->is_global()) {
VISIT_FOR_VALUE(expr->value());
HandleGlobalVariableAssignment(var, Top(), expr->position(), expr->id());

Powered by Google App Engine
This is Rietveld 408576698