ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
| 30 | #include "bootstrapper.h" |
| 31 | #include "codegen-inl.h" |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 32 | #include "compilation-cache.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 33 | #include "compiler.h" |
| 34 | #include "debug.h" |
| 35 | #include "scopes.h" |
| 36 | #include "rewriter.h" |
| 37 | #include "usage-analyzer.h" |
| 38 | |
| 39 | namespace v8 { namespace internal { |
| 40 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 41 | static Handle<Code> MakeCode(FunctionLiteral* literal, |
| 42 | Handle<Script> script, |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 43 | Handle<Context> context, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 44 | bool is_eval) { |
| 45 | ASSERT(literal != NULL); |
| 46 | |
| 47 | // Rewrite the AST by introducing .result assignments where needed. |
| 48 | if (!Rewriter::Process(literal) || !AnalyzeVariableUsage(literal)) { |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 49 | // Signal a stack overflow by returning a null handle. The stack |
| 50 | // overflow exception will be thrown by the caller. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 51 | return Handle<Code>::null(); |
| 52 | } |
| 53 | |
| 54 | // Compute top scope and allocate variables. For lazy compilation |
| 55 | // the top scope only contains the single lazily compiled function, |
| 56 | // so this doesn't re-allocate variables repeatedly. |
| 57 | Scope* top = literal->scope(); |
| 58 | while (top->outer_scope() != NULL) top = top->outer_scope(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 59 | top->AllocateVariables(context); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 60 | |
| 61 | #ifdef DEBUG |
| 62 | if (Bootstrapper::IsActive() ? |
| 63 | FLAG_print_builtin_scopes : |
| 64 | FLAG_print_scopes) { |
| 65 | literal->scope()->Print(); |
| 66 | } |
| 67 | #endif |
| 68 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 69 | // Optimize the AST. |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 70 | if (!Rewriter::Optimize(literal)) { |
| 71 | // Signal a stack overflow by returning a null handle. The stack |
| 72 | // overflow exception will be thrown by the caller. |
| 73 | return Handle<Code>::null(); |
| 74 | } |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 75 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 76 | // Generate code and return it. |
| 77 | Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval); |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | static Handle<JSFunction> MakeFunction(bool is_global, |
| 83 | bool is_eval, |
| 84 | Handle<Script> script, |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 85 | Handle<Context> context, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 86 | v8::Extension* extension, |
| 87 | ScriptDataImpl* pre_data) { |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 88 | ZoneScope zone_scope(DELETE_ON_EXIT); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 89 | |
| 90 | // Make sure we have an initial stack limit. |
| 91 | StackGuard guard; |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 92 | PostponeInterruptsScope postpone; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 93 | |
| 94 | // Notify debugger |
| 95 | Debugger::OnBeforeCompile(script); |
| 96 | |
| 97 | // Only allow non-global compiles for eval. |
| 98 | ASSERT(is_eval || is_global); |
| 99 | |
| 100 | // Build AST. |
| 101 | FunctionLiteral* lit = MakeAST(is_global, script, extension, pre_data); |
| 102 | |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 103 | // Check for parse errors. |
| 104 | if (lit == NULL) { |
| 105 | ASSERT(Top::has_pending_exception()); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 106 | return Handle<JSFunction>::null(); |
| 107 | } |
| 108 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 109 | // Measure how long it takes to do the compilation; only take the |
| 110 | // rest of the function into account to avoid overlap with the |
| 111 | // parsing statistics. |
| 112 | StatsRate* rate = is_eval |
| 113 | ? &Counters::compile_eval |
| 114 | : &Counters::compile; |
| 115 | StatsRateScope timer(rate); |
| 116 | |
| 117 | // Compile the code. |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 118 | Handle<Code> code = MakeCode(lit, script, context, is_eval); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 119 | |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 120 | // Check for stack-overflow exceptions. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 121 | if (code.is_null()) { |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 122 | Top::StackOverflow(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 123 | return Handle<JSFunction>::null(); |
| 124 | } |
| 125 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 126 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 127 | // Log the code generation for the script. Check explicit whether logging is |
| 128 | // to avoid allocating when not required. |
| 129 | if (Logger::is_enabled()) { |
| 130 | if (script->name()->IsString()) { |
| 131 | SmartPointer<char> data = |
| 132 | String::cast(script->name())->ToCString(DISALLOW_NULLS); |
| 133 | LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, *data)); |
| 134 | } else { |
| 135 | LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, "")); |
| 136 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 137 | } |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 138 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 139 | |
| 140 | // Allocate function. |
| 141 | Handle<JSFunction> fun = |
| 142 | Factory::NewFunctionBoilerplate(lit->name(), |
| 143 | lit->materialized_literal_count(), |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 144 | lit->contains_array_literal(), |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 145 | code); |
| 146 | |
| 147 | CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(), |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 148 | RelocInfo::kNoPosition, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 149 | lit->start_position(), lit->end_position(), |
| 150 | lit->is_expression(), true, script); |
| 151 | |
| 152 | // Hint to the runtime system used when allocating space for initial |
| 153 | // property space by setting the expected number of properties for |
| 154 | // the instances of the function. |
| 155 | SetExpectedNofPropertiesFromEstimate(fun, lit->expected_property_count()); |
| 156 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 157 | // Notify debugger |
| 158 | Debugger::OnAfterCompile(script, fun); |
| 159 | |
| 160 | return fun; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; |
| 165 | |
| 166 | |
| 167 | Handle<JSFunction> Compiler::Compile(Handle<String> source, |
mads.s.ager | cbaa060 | 2008-08-14 13:41:48 +0000 | [diff] [blame] | 168 | Handle<Object> script_name, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 169 | int line_offset, int column_offset, |
| 170 | v8::Extension* extension, |
| 171 | ScriptDataImpl* input_pre_data) { |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 172 | int source_length = source->length(); |
| 173 | Counters::total_load_size.Increment(source_length); |
| 174 | Counters::total_compile_size.Increment(source_length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 175 | |
| 176 | // The VM is in the COMPILER state until exiting this function. |
| 177 | VMState state(COMPILER); |
| 178 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 179 | // Do a lookup in the compilation cache but not for extensions. |
| 180 | Handle<JSFunction> result; |
| 181 | if (extension == NULL) { |
| 182 | result = CompilationCache::LookupScript(source, |
| 183 | script_name, |
| 184 | line_offset, |
| 185 | column_offset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 186 | } |
| 187 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 188 | if (result.is_null()) { |
| 189 | // No cache entry found. Do pre-parsing and compile the script. |
| 190 | ScriptDataImpl* pre_data = input_pre_data; |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 191 | if (pre_data == NULL && source_length >= FLAG_min_preparse_length) { |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 192 | Access<SafeStringInputBuffer> buf(&safe_string_input_buffer); |
| 193 | buf->Reset(source.location()); |
| 194 | pre_data = PreParse(buf.value(), extension); |
| 195 | } |
| 196 | |
| 197 | // Create a script object describing the script to be compiled. |
| 198 | Handle<Script> script = Factory::NewScript(source); |
| 199 | if (!script_name.is_null()) { |
| 200 | script->set_name(*script_name); |
| 201 | script->set_line_offset(Smi::FromInt(line_offset)); |
| 202 | script->set_column_offset(Smi::FromInt(column_offset)); |
| 203 | } |
| 204 | |
| 205 | // Compile the function and add it to the cache. |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 206 | result = MakeFunction(true, |
| 207 | false, |
| 208 | script, |
| 209 | Handle<Context>::null(), |
| 210 | extension, |
| 211 | pre_data); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 212 | if (extension == NULL && !result.is_null()) { |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 213 | CompilationCache::PutFunction(source, CompilationCache::SCRIPT, result); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | // Get rid of the pre-parsing data (if necessary). |
| 217 | if (input_pre_data == NULL && pre_data != NULL) { |
| 218 | delete pre_data; |
| 219 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 220 | } |
| 221 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 222 | if (result.is_null()) Top::ReportPendingMessages(); |
| 223 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 224 | return result; |
| 225 | } |
| 226 | |
| 227 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 228 | Handle<JSFunction> Compiler::CompileEval(Handle<String> source, |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 229 | Handle<Context> context, |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 230 | int line_offset, |
| 231 | bool is_global) { |
ager@chromium.org | c3e50d8 | 2008-11-05 11:53:10 +0000 | [diff] [blame] | 232 | int source_length = source->length(); |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 233 | Counters::total_eval_size.Increment(source_length); |
| 234 | Counters::total_compile_size.Increment(source_length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 235 | |
| 236 | // The VM is in the COMPILER state until exiting this function. |
| 237 | VMState state(COMPILER); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 238 | CompilationCache::Entry entry = is_global |
| 239 | ? CompilationCache::EVAL_GLOBAL |
| 240 | : CompilationCache::EVAL_CONTEXTUAL; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 241 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 242 | // Do a lookup in the compilation cache; if the entry is not there, |
| 243 | // invoke the compiler and add the result to the cache. |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 244 | Handle<JSFunction> result = |
| 245 | CompilationCache::LookupEval(source, context, entry); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 246 | if (result.is_null()) { |
| 247 | // Create a script object describing the script to be compiled. |
| 248 | Handle<Script> script = Factory::NewScript(source); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 249 | script->set_line_offset(Smi::FromInt(line_offset)); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 250 | result = MakeFunction(is_global, true, script, context, NULL, NULL); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 251 | if (!result.is_null()) { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 252 | CompilationCache::PutEvalFunction(source, context, entry, result); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 253 | } |
| 254 | } |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 255 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 256 | return result; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 260 | bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared, |
| 261 | int loop_nesting) { |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 262 | ZoneScope zone_scope(DELETE_ON_EXIT); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 263 | |
| 264 | // The VM is in the COMPILER state until exiting this function. |
| 265 | VMState state(COMPILER); |
| 266 | |
| 267 | // Make sure we have an initial stack limit. |
| 268 | StackGuard guard; |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 269 | PostponeInterruptsScope postpone; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 270 | |
| 271 | // Compute name, source code and script data. |
| 272 | Handle<String> name(String::cast(shared->name())); |
| 273 | Handle<Script> script(Script::cast(shared->script())); |
| 274 | |
| 275 | int start_position = shared->start_position(); |
| 276 | int end_position = shared->end_position(); |
| 277 | bool is_expression = shared->is_expression(); |
| 278 | Counters::total_compile_size.Increment(end_position - start_position); |
| 279 | |
| 280 | // Generate the AST for the lazily compiled function. The AST may be |
| 281 | // NULL in case of parser stack overflow. |
| 282 | FunctionLiteral* lit = MakeLazyAST(script, name, |
| 283 | start_position, |
| 284 | end_position, |
| 285 | is_expression); |
| 286 | |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 287 | // Check for parse errors. |
| 288 | if (lit == NULL) { |
| 289 | ASSERT(Top::has_pending_exception()); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 290 | return false; |
| 291 | } |
| 292 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 293 | // Update the loop nesting in the function literal. |
| 294 | lit->set_loop_nesting(loop_nesting); |
| 295 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 296 | // Measure how long it takes to do the lazy compilation; only take |
| 297 | // the rest of the function into account to avoid overlap with the |
| 298 | // lazy parsing statistics. |
| 299 | StatsRateScope timer(&Counters::compile_lazy); |
| 300 | |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 301 | // Compile the code. |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 302 | Handle<Code> code = MakeCode(lit, script, Handle<Context>::null(), false); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 303 | |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 304 | // Check for stack-overflow exception. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 305 | if (code.is_null()) { |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 306 | Top::StackOverflow(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 307 | return false; |
| 308 | } |
| 309 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 310 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 311 | // Log the code generation. If source information is available include script |
| 312 | // name and line number. Check explicit whether logging is enabled as finding |
| 313 | // the line number is not for free. |
| 314 | if (Logger::is_enabled()) { |
| 315 | if (script->name()->IsString()) { |
| 316 | int line_num = script->GetLineNumber(start_position); |
| 317 | if (line_num > 0) { |
| 318 | line_num += script->line_offset()->value() + 1; |
| 319 | } |
| 320 | LOG(CodeCreateEvent("LazyCompile", *code, *lit->name(), |
| 321 | String::cast(script->name()), line_num)); |
| 322 | } else { |
| 323 | LOG(CodeCreateEvent("LazyCompile", *code, *lit->name())); |
| 324 | } |
| 325 | } |
| 326 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 327 | |
| 328 | // Update the shared function info with the compiled code. |
| 329 | shared->set_code(*code); |
| 330 | |
| 331 | // Set the expected number of properties for instances. |
| 332 | SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
| 333 | |
| 334 | // Check the function has compiled code. |
| 335 | ASSERT(shared->is_compiled()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 336 | return true; |
| 337 | } |
| 338 | |
| 339 | |
| 340 | } } // namespace v8::internal |