Chromium Code Reviews| Index: src/hydrogen.cc |
| =================================================================== |
| --- src/hydrogen.cc (revision 5936) |
| +++ src/hydrogen.cc (working copy) |
| @@ -2113,6 +2113,22 @@ |
| } |
| +void HGraphBuilder::VisitForTypeofValue(Expression* expr) { |
|
Kevin Millikin (Chromium)
2010/12/09 13:16:51
It seems to me that "parent is typeof" is just a f
fschneider
2010/12/22 16:02:34
Done.
|
| + VariableProxy* proxy = expr->AsVariableProxy(); |
| + if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) { |
|
Kevin Millikin (Chromium)
2010/12/09 13:16:51
I think you can just ask the proxy is_this (and ma
fschneider
2010/12/22 16:02:34
Done. This part of the code is now gone.
|
| +#ifdef DEBUG |
| + int original_height = environment()->values()->length(); |
| +#endif |
| + HandleGlobalVariableLoad(proxy, true); // Inside typeof. |
| + // Generic global loads always have a side effect. |
| + AddSimulate(expr->id()); |
| + ASSERT(environment()->values()->length() == original_height + 1); |
| + } else { |
| + VisitForValue(expr); |
| + } |
| +} |
| + |
| + |
| HValue* HGraphBuilder::VisitArgument(Expression* expr) { |
| VisitForValue(expr); |
| if (HasStackOverflow() || !subgraph()->HasExit()) return NULL; |
| @@ -2940,7 +2956,9 @@ |
| void HGraphBuilder::LookupGlobalPropertyCell(VariableProxy* expr, |
|
Kevin Millikin (Chromium)
2010/12/09 13:16:51
It seems like it would be cleaner for this functio
fschneider
2010/12/22 16:02:34
I wanted to be able to use the BAILOUT macro from
|
| LookupResult* lookup, |
| - bool is_store) { |
| + bool is_store, |
| + bool* is_generic) { |
| + *is_generic = true; |
| if (expr->is_this()) { |
| BAILOUT("global this reference"); |
| } |
| @@ -2949,32 +2967,30 @@ |
| } |
| Handle<GlobalObject> global(graph()->info()->global_object()); |
| global->Lookup(*expr->name(), lookup); |
| - if (!lookup->IsProperty()) { |
| - BAILOUT("global variable cell not yet introduced"); |
| - } |
| - if (lookup->type() != NORMAL) { |
| - BAILOUT("global variable has accessors"); |
| - } |
| + if (!lookup->IsProperty()) return; |
| + if (lookup->type() != NORMAL) return; |
| if (is_store && lookup->IsReadOnly()) { |
| - BAILOUT("read-only global variable"); |
| + BAILOUT("store to read-only global variable"); |
| } |
| + *is_generic = false; |
| } |
| -void HGraphBuilder::HandleGlobalVariableLoad(VariableProxy* expr) { |
| +void HGraphBuilder::HandleGlobalVariableLoad(VariableProxy* expr, |
|
Kevin Millikin (Chromium)
2010/12/09 13:16:51
We need to restore some sanity to these helper fun
fschneider
2010/12/22 16:02:34
Done.
|
| + bool inside_typeof) { |
| LookupResult lookup; |
| - LookupGlobalPropertyCell(expr, &lookup, false); |
| + bool is_generic = true; |
| + LookupGlobalPropertyCell(expr, &lookup, false, &is_generic); |
| CHECK_BAILOUT; |
| Handle<GlobalObject> global(graph()->info()->global_object()); |
| - // TODO(3039103): Handle global property load through an IC call when access |
| - // checks are enabled. |
| - if (global->IsAccessCheckNeeded()) { |
| - BAILOUT("global object requires access check"); |
| + if (is_generic || global->IsAccessCheckNeeded()) { |
| + PushAndAdd(new HLoadGlobalGeneric(expr->var()->name(), inside_typeof)); |
|
Kevin Millikin (Chromium)
2010/12/09 13:16:51
Here you could just ask the ast_context if it is a
fschneider
2010/12/22 16:02:34
Done.
|
| + } else { |
| + Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); |
| + bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly(); |
| + PushAndAdd(new HLoadGlobal(cell, check_hole)); |
| } |
| - Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); |
| - bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly(); |
| - PushAndAdd(new HLoadGlobal(cell, check_hole)); |
| } |
| @@ -2988,7 +3004,7 @@ |
| } |
| Push(environment()->Lookup(variable)); |
| } else if (variable->is_global()) { |
| - HandleGlobalVariableLoad(expr); |
| + HandleGlobalVariableLoad(expr, false); // Not inside typeof. |
| } else { |
| BAILOUT("reference to non-stack-allocated/non-global variable"); |
| } |
| @@ -3340,14 +3356,19 @@ |
| HValue* value, |
| int position) { |
| LookupResult lookup; |
| - LookupGlobalPropertyCell(proxy, &lookup, true); |
| + bool is_generic; |
| + LookupGlobalPropertyCell(proxy, &lookup, true, &is_generic); |
| CHECK_BAILOUT; |
| Handle<GlobalObject> global(graph()->info()->global_object()); |
| - Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); |
| - HInstruction* instr = new HStoreGlobal(value, cell); |
| - instr->set_position(position); |
| - AddInstruction(instr); |
| + if (!is_generic && !global->IsAccessCheckNeeded()) { |
| + Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); |
| + HInstruction* instr = new HStoreGlobal(value, cell); |
| + instr->set_position(position); |
| + AddInstruction(instr); |
| + } else { |
| + BAILOUT("unsupported store to global"); |
| + } |
| } |
| @@ -4400,7 +4421,8 @@ |
| } |
| PushAndAdd(instr); |
| } else if (op == Token::TYPEOF) { |
| - VISIT_FOR_VALUE(expr->expression()); |
| + VisitForTypeofValue(expr->expression()); |
| + if (HasStackOverflow()) return; |
| HValue* value = Pop(); |
| PushAndAdd(new HTypeof(value)); |
| } else { |
| @@ -4701,7 +4723,8 @@ |
| if ((expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT) && |
| left_unary != NULL && left_unary->op() == Token::TYPEOF && |
| right_literal != NULL && right_literal->handle()->IsString()) { |
| - VISIT_FOR_VALUE(left_unary->expression()); |
| + VisitForTypeofValue(left_unary->expression()); |
| + if (HasStackOverflow()) return; |
| HValue* left = Pop(); |
| HInstruction* instr = new HTypeofIs(left, |
| Handle<String>::cast(right_literal->handle())); |