OLD | NEW |
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 3128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3139 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 3139 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
3140 ASSERT(!HasStackOverflow()); | 3140 ASSERT(!HasStackOverflow()); |
3141 ASSERT(current_block() != NULL); | 3141 ASSERT(current_block() != NULL); |
3142 ASSERT(current_block()->HasPredecessor()); | 3142 ASSERT(current_block()->HasPredecessor()); |
3143 Variable* variable = expr->var(); | 3143 Variable* variable = expr->var(); |
3144 if (variable->mode() == Variable::LET) { | 3144 if (variable->mode() == Variable::LET) { |
3145 return Bailout("reference to let variable"); | 3145 return Bailout("reference to let variable"); |
3146 } | 3146 } |
3147 switch (variable->location()) { | 3147 switch (variable->location()) { |
3148 case Variable::UNALLOCATED: { | 3148 case Variable::UNALLOCATED: { |
| 3149 // Handle known global constants like 'undefined' specially to avoid a |
| 3150 // load from a global cell for them. |
| 3151 Handle<Object> constant_value = |
| 3152 isolate()->factory()->GlobalConstantFor(variable->name()); |
| 3153 if (!constant_value.is_null()) { |
| 3154 HConstant* instr = |
| 3155 new(zone()) HConstant(constant_value, Representation::Tagged()); |
| 3156 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 3157 } |
| 3158 |
3149 LookupResult lookup; | 3159 LookupResult lookup; |
3150 GlobalPropertyAccess type = | 3160 GlobalPropertyAccess type = |
3151 LookupGlobalProperty(variable, &lookup, false); | 3161 LookupGlobalProperty(variable, &lookup, false); |
3152 | 3162 |
3153 if (type == kUseCell && | 3163 if (type == kUseCell && |
3154 info()->global_object()->IsAccessCheckNeeded()) { | 3164 info()->global_object()->IsAccessCheckNeeded()) { |
3155 type = kUseGeneric; | 3165 type = kUseGeneric; |
3156 } | 3166 } |
3157 | 3167 |
3158 if (type == kUseCell) { | 3168 if (type == kUseCell) { |
(...skipping 3700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6859 } | 6869 } |
6860 } | 6870 } |
6861 | 6871 |
6862 #ifdef DEBUG | 6872 #ifdef DEBUG |
6863 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 6873 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
6864 if (allocator_ != NULL) allocator_->Verify(); | 6874 if (allocator_ != NULL) allocator_->Verify(); |
6865 #endif | 6875 #endif |
6866 } | 6876 } |
6867 | 6877 |
6868 } } // namespace v8::internal | 6878 } } // namespace v8::internal |
OLD | NEW |