| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 // Note that we always add an unresolved proxy even if it's not | 1731 // Note that we always add an unresolved proxy even if it's not |
| 1732 // used, simply because we don't know in this method (w/o extra | 1732 // used, simply because we don't know in this method (w/o extra |
| 1733 // parameters) if the proxy is needed or not. The proxy will be | 1733 // parameters) if the proxy is needed or not. The proxy will be |
| 1734 // bound during variable resolution time unless it was pre-bound | 1734 // bound during variable resolution time unless it was pre-bound |
| 1735 // below. | 1735 // below. |
| 1736 // | 1736 // |
| 1737 // WARNING: This will lead to multiple declaration nodes for the | 1737 // WARNING: This will lead to multiple declaration nodes for the |
| 1738 // same variable if it is declared several times. This is not a | 1738 // same variable if it is declared several times. This is not a |
| 1739 // semantic issue as long as we keep the source order, but it may be | 1739 // semantic issue as long as we keep the source order, but it may be |
| 1740 // a performance issue since it may lead to repeated | 1740 // a performance issue since it may lead to repeated |
| 1741 // Runtime::DeclareContextSlot() calls. | 1741 // RuntimeHidden_DeclareContextSlot calls. |
| 1742 declaration_scope->AddDeclaration(declaration); | 1742 declaration_scope->AddDeclaration(declaration); |
| 1743 | 1743 |
| 1744 if (mode == CONST_LEGACY && declaration_scope->is_global_scope()) { | 1744 if (mode == CONST_LEGACY && declaration_scope->is_global_scope()) { |
| 1745 // For global const variables we bind the proxy to a variable. | 1745 // For global const variables we bind the proxy to a variable. |
| 1746 ASSERT(resolve); // should be set by all callers | 1746 ASSERT(resolve); // should be set by all callers |
| 1747 Variable::Kind kind = Variable::NORMAL; | 1747 Variable::Kind kind = Variable::NORMAL; |
| 1748 var = new(zone()) Variable( | 1748 var = new(zone()) Variable( |
| 1749 declaration_scope, name, mode, true, kind, | 1749 declaration_scope, name, mode, true, kind, |
| 1750 kNeedsInitialization, proxy->interface()); | 1750 kNeedsInitialization, proxy->interface()); |
| 1751 } else if (declaration_scope->is_eval_scope() && | 1751 } else if (declaration_scope->is_eval_scope() && |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 if (is_const) { | 2209 if (is_const) { |
| 2210 arguments->Add(value, zone()); | 2210 arguments->Add(value, zone()); |
| 2211 value = NULL; // zap the value to avoid the unnecessary assignment | 2211 value = NULL; // zap the value to avoid the unnecessary assignment |
| 2212 | 2212 |
| 2213 // Construct the call to Runtime_InitializeConstGlobal | 2213 // Construct the call to Runtime_InitializeConstGlobal |
| 2214 // and add it to the initialization statement block. | 2214 // and add it to the initialization statement block. |
| 2215 // Note that the function does different things depending on | 2215 // Note that the function does different things depending on |
| 2216 // the number of arguments (1 or 2). | 2216 // the number of arguments (1 or 2). |
| 2217 initialize = factory()->NewCallRuntime( | 2217 initialize = factory()->NewCallRuntime( |
| 2218 isolate()->factory()->InitializeConstGlobal_string(), | 2218 isolate()->factory()->InitializeConstGlobal_string(), |
| 2219 Runtime::FunctionForId(Runtime::kInitializeConstGlobal), | 2219 Runtime::FunctionForId(Runtime::kHiddenInitializeConstGlobal), |
| 2220 arguments, pos); | 2220 arguments, pos); |
| 2221 } else { | 2221 } else { |
| 2222 // Add strict mode. | 2222 // Add strict mode. |
| 2223 // We may want to pass singleton to avoid Literal allocations. | 2223 // We may want to pass singleton to avoid Literal allocations. |
| 2224 StrictMode strict_mode = initialization_scope->strict_mode(); | 2224 StrictMode strict_mode = initialization_scope->strict_mode(); |
| 2225 arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone()); | 2225 arguments->Add(factory()->NewNumberLiteral(strict_mode, pos), zone()); |
| 2226 | 2226 |
| 2227 // Be careful not to assign a value to the global variable if | 2227 // Be careful not to assign a value to the global variable if |
| 2228 // we're in a with. The initialization value should not | 2228 // we're in a with. The initialization value should not |
| 2229 // necessarily be stored in the global object in that case, | 2229 // necessarily be stored in the global object in that case, |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3425 RelocInfo::kNoPosition), | 3425 RelocInfo::kNoPosition), |
| 3426 RelocInfo::kNoPosition), zone()); | 3426 RelocInfo::kNoPosition), zone()); |
| 3427 } | 3427 } |
| 3428 | 3428 |
| 3429 // For generators, allocate and yield an iterator on function entry. | 3429 // For generators, allocate and yield an iterator on function entry. |
| 3430 if (is_generator) { | 3430 if (is_generator) { |
| 3431 ZoneList<Expression*>* arguments = | 3431 ZoneList<Expression*>* arguments = |
| 3432 new(zone()) ZoneList<Expression*>(0, zone()); | 3432 new(zone()) ZoneList<Expression*>(0, zone()); |
| 3433 CallRuntime* allocation = factory()->NewCallRuntime( | 3433 CallRuntime* allocation = factory()->NewCallRuntime( |
| 3434 isolate()->factory()->empty_string(), | 3434 isolate()->factory()->empty_string(), |
| 3435 Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject), | 3435 Runtime::FunctionForId(Runtime::kHiddenCreateJSGeneratorObject), |
| 3436 arguments, pos); | 3436 arguments, pos); |
| 3437 VariableProxy* init_proxy = factory()->NewVariableProxy( | 3437 VariableProxy* init_proxy = factory()->NewVariableProxy( |
| 3438 function_state_->generator_object_variable()); | 3438 function_state_->generator_object_variable()); |
| 3439 Assignment* assignment = factory()->NewAssignment( | 3439 Assignment* assignment = factory()->NewAssignment( |
| 3440 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); | 3440 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); |
| 3441 VariableProxy* get_proxy = factory()->NewVariableProxy( | 3441 VariableProxy* get_proxy = factory()->NewVariableProxy( |
| 3442 function_state_->generator_object_variable()); | 3442 function_state_->generator_object_variable()); |
| 3443 Yield* yield = factory()->NewYield( | 3443 Yield* yield = factory()->NewYield( |
| 3444 get_proxy, assignment, Yield::INITIAL, RelocInfo::kNoPosition); | 3444 get_proxy, assignment, Yield::INITIAL, RelocInfo::kNoPosition); |
| 3445 body->Add(factory()->NewExpressionStatement( | 3445 body->Add(factory()->NewExpressionStatement( |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4697 ASSERT(info()->isolate()->has_pending_exception()); | 4697 ASSERT(info()->isolate()->has_pending_exception()); |
| 4698 } else { | 4698 } else { |
| 4699 result = ParseProgram(); | 4699 result = ParseProgram(); |
| 4700 } | 4700 } |
| 4701 } | 4701 } |
| 4702 info()->SetFunction(result); | 4702 info()->SetFunction(result); |
| 4703 return (result != NULL); | 4703 return (result != NULL); |
| 4704 } | 4704 } |
| 4705 | 4705 |
| 4706 } } // namespace v8::internal | 4706 } } // namespace v8::internal |
| OLD | NEW |