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

Unified Diff: src/hydrogen.cc

Issue 7826009: Support declarations of context allocated locals in Crankshaft. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/hydrogen.cc
===================================================================
--- src/hydrogen.cc (revision 9109)
+++ src/hydrogen.cc (working copy)
@@ -2298,11 +2298,7 @@
// Handle implicit declaration of the function name in named function
// expressions before other declarations.
if (scope->is_function_scope() && scope->function() != NULL) {
- if (!scope->function()->IsStackAllocated()) {
- Bailout("unsupported declaration");
- return NULL;
- }
- environment()->Bind(scope->function(), graph()->GetConstantHole());
+ EmitDeclaration(scope->function(), Variable::CONST, NULL);
}
VisitDeclarations(scope->declarations());
AddSimulate(AstNode::kDeclarationsId);
@@ -5822,20 +5818,52 @@
void HGraphBuilder::VisitDeclaration(Declaration* decl) {
- // We support only declarations that do not require code generation.
- Variable* var = decl->proxy()->var();
- if (!var->IsStackAllocated() ||
- decl->mode() == Variable::LET) {
- return Bailout("unsupported declaration");
- }
+ EmitDeclaration(decl->proxy(), decl->mode(), decl->fun());
+}
- if (decl->mode() == Variable::CONST) {
- ASSERT(var->IsStackAllocated());
- environment()->Bind(var, graph()->GetConstantHole());
- } else if (decl->fun() != NULL) {
- VisitForValue(decl->fun());
- HValue* function = Pop();
- environment()->Bind(var, function);
+
+void HGraphBuilder::EmitDeclaration(VariableProxy* proxy,
+ Variable::Mode mode,
+ FunctionLiteral* function) {
+ if (mode == Variable::LET) return Bailout("unsupported let declaration");
+ Variable* var = proxy->var();
+ Slot* slot = var->AsSlot();
+ ASSERT(slot != NULL);
+ switch (slot->type()) {
+ case Slot::PARAMETER:
+ case Slot::LOCAL:
+ if (mode == Variable::CONST) {
+ ASSERT(var->IsStackAllocated());
Kevin Millikin (Chromium) 2011/09/01 15:40:58 This ASSERT is trivially true, because it's in the
fschneider 2011/09/01 16:28:21 Done.
+ environment()->Bind(var, graph()->GetConstantHole());
+ } else if (function != NULL) {
+ VisitForValue(function);
+ HValue* function_value = Pop();
+ environment()->Bind(var, function_value);
+ }
+ break;
+ case Slot::CONTEXT: {
+ HValue* context = environment()->LookupContext();
+ if (mode == Variable::CONST) {
+ HStoreContextSlot* store =
+ new HStoreContextSlot(context,
+ slot->index(),
+ graph()->GetConstantHole());
+ AddInstruction(store);
+ if (store->HasSideEffects()) AddSimulate(proxy->id());
+ } else if (function != NULL) {
+ VisitForValue(function);
+ HValue* function_value = Pop();
+ HStoreContextSlot* store =
+ new HStoreContextSlot(context,
+ slot->index(),
+ function_value);
+ AddInstruction(store);
+ if (store->HasSideEffects()) AddSimulate(proxy->id());
+ }
+ break;
+ }
+ case Slot::LOOKUP:
+ return Bailout("unsupported lookup slot in declaration");
}
}

Powered by Google App Engine
This is Rietveld 408576698