OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 void FastCodeGenSyntaxChecker::VisitVariableProxy(VariableProxy* expr) { | 214 void FastCodeGenSyntaxChecker::VisitVariableProxy(VariableProxy* expr) { |
215 // Only global variable references are supported. | 215 // Only global variable references are supported. |
216 Variable* var = expr->var(); | 216 Variable* var = expr->var(); |
217 if (!var->is_global() || var->is_this()) BAILOUT("Non-global variable"); | 217 if (!var->is_global() || var->is_this()) BAILOUT("Non-global variable"); |
218 | 218 |
219 // Check if the global variable is existing and non-deletable. | 219 // Check if the global variable is existing and non-deletable. |
220 if (info()->has_global_object()) { | 220 if (info()->has_global_object()) { |
221 LookupResult lookup; | 221 LookupResult lookup; |
222 info()->global_object()->Lookup(*expr->name(), &lookup); | 222 info()->global_object()->Lookup(*expr->name(), &lookup); |
223 if (!lookup.IsValid() || !lookup.IsDontDelete()) { | 223 if (!lookup.IsValid()) { |
224 BAILOUT("Non-existing or deletable global variable"); | 224 BAILOUT("Non-existing global variable"); |
| 225 } |
| 226 // We do not handle global variables with accessors or interceptors. |
| 227 if (lookup.type() != NORMAL) { |
| 228 BAILOUT("Global variable with accessors or interceptors."); |
| 229 } |
| 230 // We do not handle deletable global variables. |
| 231 if (!lookup.IsDontDelete()) { |
| 232 BAILOUT("Deletable global variable"); |
225 } | 233 } |
226 } | 234 } |
227 } | 235 } |
228 | 236 |
229 | 237 |
230 void FastCodeGenSyntaxChecker::VisitLiteral(Literal* expr) { | 238 void FastCodeGenSyntaxChecker::VisitLiteral(Literal* expr) { |
231 BAILOUT("Literal"); | 239 BAILOUT("Literal"); |
232 } | 240 } |
233 | 241 |
234 | 242 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 UNREACHABLE(); | 574 UNREACHABLE(); |
567 } | 575 } |
568 | 576 |
569 | 577 |
570 void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 578 void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
571 ASSERT(expr->var()->is_global() && !expr->var()->is_this()); | 579 ASSERT(expr->var()->is_global() && !expr->var()->is_this()); |
572 // Check if we can compile a global variable load directly from the cell. | 580 // Check if we can compile a global variable load directly from the cell. |
573 ASSERT(info()->has_global_object()); | 581 ASSERT(info()->has_global_object()); |
574 LookupResult lookup; | 582 LookupResult lookup; |
575 info()->global_object()->Lookup(*expr->name(), &lookup); | 583 info()->global_object()->Lookup(*expr->name(), &lookup); |
576 // We only support DontDelete properties for now. | 584 // We only support normal (non-accessor/interceptor) DontDelete properties |
| 585 // for now. |
577 ASSERT(lookup.IsValid()); | 586 ASSERT(lookup.IsValid()); |
| 587 ASSERT_EQ(NORMAL, lookup.type()); |
578 ASSERT(lookup.IsDontDelete()); | 588 ASSERT(lookup.IsDontDelete()); |
579 Handle<Object> cell(info()->global_object()->GetPropertyCell(&lookup)); | 589 Handle<Object> cell(info()->global_object()->GetPropertyCell(&lookup)); |
580 | 590 |
581 // Global variable lookups do not have side effects, so we do not need to | 591 // Global variable lookups do not have side effects, so we do not need to |
582 // emit code if we are in an effect context. | 592 // emit code if we are in an effect context. |
583 if (!destination().is(no_reg)) { | 593 if (!destination().is(no_reg)) { |
584 Comment cmnt(masm(), ";; Global"); | 594 Comment cmnt(masm(), ";; Global"); |
585 if (FLAG_print_ir) { | 595 if (FLAG_print_ir) { |
586 SmartPointer<char> name = expr->name()->ToCString(); | 596 SmartPointer<char> name = expr->name()->ToCString(); |
587 PrintF("%d: t%d = Global(%s)\n", expr->num(), expr->num(), *name); | 597 PrintF("%d: t%d = Global(%s)\n", expr->num(), expr->num(), *name); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 734 |
725 | 735 |
726 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 736 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
727 UNREACHABLE(); | 737 UNREACHABLE(); |
728 } | 738 } |
729 | 739 |
730 #undef __ | 740 #undef __ |
731 | 741 |
732 | 742 |
733 } } // namespace v8::internal | 743 } } // namespace v8::internal |
OLD | NEW |