| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 #ifdef DEBUG | 60 #ifdef DEBUG |
| 61 if (Bootstrapper::IsActive() ? | 61 if (Bootstrapper::IsActive() ? |
| 62 FLAG_print_builtin_scopes : | 62 FLAG_print_builtin_scopes : |
| 63 FLAG_print_scopes) { | 63 FLAG_print_scopes) { |
| 64 literal->scope()->Print(); | 64 literal->scope()->Print(); |
| 65 } | 65 } |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 // Optimize the AST. | 68 // Optimize the AST. |
| 69 Rewriter::Optimize(literal); | 69 if (!Rewriter::Optimize(literal)) { |
| 70 // Signal a stack overflow by returning a null handle. The stack |
| 71 // overflow exception will be thrown by the caller. |
| 72 return Handle<Code>::null(); |
| 73 } |
| 70 | 74 |
| 71 // Generate code and return it. | 75 // Generate code and return it. |
| 72 Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval); | 76 Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval); |
| 73 return result; | 77 return result; |
| 74 } | 78 } |
| 75 | 79 |
| 76 | 80 |
| 77 static Handle<JSFunction> MakeFunction(bool is_global, | 81 static Handle<JSFunction> MakeFunction(bool is_global, |
| 78 bool is_eval, | 82 bool is_eval, |
| 79 Handle<Script> script, | 83 Handle<Script> script, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 206 } |
| 203 } | 207 } |
| 204 | 208 |
| 205 return result; | 209 return result; |
| 206 } | 210 } |
| 207 | 211 |
| 208 | 212 |
| 209 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, | 213 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, |
| 210 int line_offset, | 214 int line_offset, |
| 211 bool is_global) { | 215 bool is_global) { |
| 212 StringShape source_shape(*source); | 216 int source_length = source->length(); |
| 213 int source_length = source->length(source_shape); | |
| 214 Counters::total_eval_size.Increment(source_length); | 217 Counters::total_eval_size.Increment(source_length); |
| 215 Counters::total_compile_size.Increment(source_length); | 218 Counters::total_compile_size.Increment(source_length); |
| 216 | 219 |
| 217 // The VM is in the COMPILER state until exiting this function. | 220 // The VM is in the COMPILER state until exiting this function. |
| 218 VMState state(COMPILER); | 221 VMState state(COMPILER); |
| 219 CompilationCache::Entry entry = is_global | 222 CompilationCache::Entry entry = is_global |
| 220 ? CompilationCache::EVAL_GLOBAL | 223 ? CompilationCache::EVAL_GLOBAL |
| 221 : CompilationCache::EVAL_CONTEXTUAL; | 224 : CompilationCache::EVAL_CONTEXTUAL; |
| 222 | 225 |
| 223 // Do a lookup in the compilation cache; if the entry is not there, | 226 // Do a lookup in the compilation cache; if the entry is not there, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 // Set the expected number of properties for instances. | 294 // Set the expected number of properties for instances. |
| 292 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 295 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
| 293 | 296 |
| 294 // Check the function has compiled code. | 297 // Check the function has compiled code. |
| 295 ASSERT(shared->is_compiled()); | 298 ASSERT(shared->is_compiled()); |
| 296 return true; | 299 return true; |
| 297 } | 300 } |
| 298 | 301 |
| 299 | 302 |
| 300 } } // namespace v8::internal | 303 } } // namespace v8::internal |
| OLD | NEW |