| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 bool is_eval) { | 45 bool is_eval) { |
| 46 ASSERT(literal != NULL); | 46 ASSERT(literal != NULL); |
| 47 | 47 |
| 48 // Rewrite the AST by introducing .result assignments where needed. | 48 // Rewrite the AST by introducing .result assignments where needed. |
| 49 if (!Rewriter::Process(literal) || !AnalyzeVariableUsage(literal)) { | 49 if (!Rewriter::Process(literal) || !AnalyzeVariableUsage(literal)) { |
| 50 // Signal a stack overflow by returning a null handle. The stack | 50 // Signal a stack overflow by returning a null handle. The stack |
| 51 // overflow exception will be thrown by the caller. | 51 // overflow exception will be thrown by the caller. |
| 52 return Handle<Code>::null(); | 52 return Handle<Code>::null(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Compute top scope and allocate variables. For lazy compilation | 55 { |
| 56 // the top scope only contains the single lazily compiled function, | 56 // Compute top scope and allocate variables. For lazy compilation |
| 57 // so this doesn't re-allocate variables repeatedly. | 57 // the top scope only contains the single lazily compiled function, |
| 58 Scope* top = literal->scope(); | 58 // so this doesn't re-allocate variables repeatedly. |
| 59 while (top->outer_scope() != NULL) top = top->outer_scope(); | 59 HistogramTimerScope timer(&Counters::variable_allocation); |
| 60 top->AllocateVariables(context); | 60 Scope* top = literal->scope(); |
| 61 while (top->outer_scope() != NULL) top = top->outer_scope(); |
| 62 top->AllocateVariables(context); |
| 63 } |
| 61 | 64 |
| 62 #ifdef DEBUG | 65 #ifdef DEBUG |
| 63 if (Bootstrapper::IsActive() ? | 66 if (Bootstrapper::IsActive() ? |
| 64 FLAG_print_builtin_scopes : | 67 FLAG_print_builtin_scopes : |
| 65 FLAG_print_scopes) { | 68 FLAG_print_scopes) { |
| 66 literal->scope()->Print(); | 69 literal->scope()->Print(); |
| 67 } | 70 } |
| 68 #endif | 71 #endif |
| 69 | 72 |
| 70 // Optimize the AST. | 73 // Optimize the AST. |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // Set the expected number of properties for instances. | 386 // Set the expected number of properties for instances. |
| 384 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 387 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
| 385 | 388 |
| 386 // Check the function has compiled code. | 389 // Check the function has compiled code. |
| 387 ASSERT(shared->is_compiled()); | 390 ASSERT(shared->is_compiled()); |
| 388 return true; | 391 return true; |
| 389 } | 392 } |
| 390 | 393 |
| 391 | 394 |
| 392 } } // namespace v8::internal | 395 } } // namespace v8::internal |
| OLD | NEW |