blob: aecdfb9aa8458a8b48eb4c1d3bc9b94387d45f2d [file] [log] [blame]
ager@chromium.org71daaf62009-04-01 07:22:49 +00001// Copyright 2009 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// 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.orgb9123622008-09-17 14:05:56 +000032#include "compilation-cache.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000033#include "compiler.h"
34#include "debug.h"
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000035#include "oprofile-agent.h"
ager@chromium.org71daaf62009-04-01 07:22:49 +000036#include "rewriter.h"
37#include "scopes.h"
38#include "usage-analyzer.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000039
kasperl@chromium.org71affb52009-05-26 05:44:31 +000040namespace v8 {
41namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000042
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000043static Handle<Code> MakeCode(FunctionLiteral* literal,
44 Handle<Script> script,
ager@chromium.org381abbb2009-02-25 13:23:22 +000045 Handle<Context> context,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000046 bool is_eval) {
47 ASSERT(literal != NULL);
48
49 // Rewrite the AST by introducing .result assignments where needed.
50 if (!Rewriter::Process(literal) || !AnalyzeVariableUsage(literal)) {
kasper.lund212ac232008-07-16 07:07:30 +000051 // Signal a stack overflow by returning a null handle. The stack
52 // overflow exception will be thrown by the caller.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000053 return Handle<Code>::null();
54 }
55
kasperl@chromium.orgb3284ad2009-05-18 06:12:45 +000056 {
57 // Compute top scope and allocate variables. For lazy compilation
58 // the top scope only contains the single lazily compiled function,
59 // so this doesn't re-allocate variables repeatedly.
60 HistogramTimerScope timer(&Counters::variable_allocation);
61 Scope* top = literal->scope();
62 while (top->outer_scope() != NULL) top = top->outer_scope();
63 top->AllocateVariables(context);
64 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000065
66#ifdef DEBUG
67 if (Bootstrapper::IsActive() ?
68 FLAG_print_builtin_scopes :
69 FLAG_print_scopes) {
70 literal->scope()->Print();
71 }
72#endif
73
kasperl@chromium.org9bbf9682008-10-30 11:53:07 +000074 // Optimize the AST.
ager@chromium.org3bf7b912008-11-17 09:09:45 +000075 if (!Rewriter::Optimize(literal)) {
76 // Signal a stack overflow by returning a null handle. The stack
77 // overflow exception will be thrown by the caller.
78 return Handle<Code>::null();
79 }
kasperl@chromium.org9bbf9682008-10-30 11:53:07 +000080
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000081 // Generate code and return it.
82 Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval);
83 return result;
84}
85
86
ager@chromium.org3a37e9b2009-04-27 09:26:21 +000087static bool IsValidJSON(FunctionLiteral* lit) {
88 if (!lit->body()->length() == 1)
89 return false;
90 Statement* stmt = lit->body()->at(0);
91 if (stmt->AsExpressionStatement() == NULL)
92 return false;
kasperl@chromium.orgb3284ad2009-05-18 06:12:45 +000093 Expression* expr = stmt->AsExpressionStatement()->expression();
ager@chromium.org3a37e9b2009-04-27 09:26:21 +000094 return expr->IsValidJSON();
95}
96
97
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000098static Handle<JSFunction> MakeFunction(bool is_global,
99 bool is_eval,
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000100 bool is_json,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000101 Handle<Script> script,
ager@chromium.org381abbb2009-02-25 13:23:22 +0000102 Handle<Context> context,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000103 v8::Extension* extension,
104 ScriptDataImpl* pre_data) {
kasperl@chromium.orgb3284ad2009-05-18 06:12:45 +0000105 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000106
107 // Make sure we have an initial stack limit.
108 StackGuard guard;
kasper.lund44510672008-07-25 07:37:58 +0000109 PostponeInterruptsScope postpone;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000110
ager@chromium.org9085a012009-05-11 19:22:57 +0000111 ASSERT(!i::Top::global_context().is_null());
112 script->set_context_data((*i::Top::global_context())->data());
ager@chromium.orge2902be2009-06-08 12:21:35 +0000113
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000114#ifdef ENABLE_DEBUGGER_SUPPORT
ager@chromium.orge2902be2009-06-08 12:21:35 +0000115 if (is_eval || is_json) {
116 script->set_compilation_type(
117 is_json ? Smi::FromInt(Script::COMPILATION_TYPE_JSON) :
118 Smi::FromInt(Script::COMPILATION_TYPE_EVAL));
119 // For eval scripts add information on the function from which eval was
120 // called.
121 if (is_eval) {
122 JavaScriptFrameIterator it;
123 script->set_eval_from_function(it.frame()->function());
124 int offset = it.frame()->pc() - it.frame()->code()->instruction_start();
125 script->set_eval_from_instructions_offset(Smi::FromInt(offset));
126 }
127 }
128
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000129 // Notify debugger
130 Debugger::OnBeforeCompile(script);
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000131#endif
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000132
133 // Only allow non-global compiles for eval.
134 ASSERT(is_eval || is_global);
135
136 // Build AST.
137 FunctionLiteral* lit = MakeAST(is_global, script, extension, pre_data);
138
kasper.lund212ac232008-07-16 07:07:30 +0000139 // Check for parse errors.
140 if (lit == NULL) {
141 ASSERT(Top::has_pending_exception());
kasper.lund212ac232008-07-16 07:07:30 +0000142 return Handle<JSFunction>::null();
143 }
144
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000145 // When parsing JSON we do an ordinary parse and then afterwards
146 // check the AST to ensure it was well-formed. If not we give a
147 // syntax error.
148 if (is_json && !IsValidJSON(lit)) {
149 HandleScope scope;
150 Handle<JSArray> args = Factory::NewJSArray(1);
151 Handle<Object> source(script->source());
152 SetElement(args, 0, source);
153 Handle<Object> result = Factory::NewSyntaxError("invalid_json", args);
154 Top::Throw(*result, NULL);
155 return Handle<JSFunction>::null();
156 }
157
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000158 // Measure how long it takes to do the compilation; only take the
159 // rest of the function into account to avoid overlap with the
160 // parsing statistics.
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000161 HistogramTimer* rate = is_eval
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000162 ? &Counters::compile_eval
163 : &Counters::compile;
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000164 HistogramTimerScope timer(rate);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000165
166 // Compile the code.
ager@chromium.org381abbb2009-02-25 13:23:22 +0000167 Handle<Code> code = MakeCode(lit, script, context, is_eval);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000168
kasper.lund212ac232008-07-16 07:07:30 +0000169 // Check for stack-overflow exceptions.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000170 if (code.is_null()) {
kasper.lund212ac232008-07-16 07:07:30 +0000171 Top::StackOverflow();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000172 return Handle<JSFunction>::null();
173 }
174
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000175#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT
iposva@chromium.org245aa852009-02-10 00:49:54 +0000176 // Log the code generation for the script. Check explicit whether logging is
177 // to avoid allocating when not required.
ager@chromium.org3e875802009-06-29 08:26:34 +0000178 if (Logger::is_logging() || OProfileAgent::is_enabled()) {
iposva@chromium.org245aa852009-02-10 00:49:54 +0000179 if (script->name()->IsString()) {
180 SmartPointer<char> data =
181 String::cast(script->name())->ToCString(DISALLOW_NULLS);
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000182 LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG,
183 *code, *data));
184 OProfileAgent::CreateNativeCodeRegion(*data,
185 code->instruction_start(),
186 code->instruction_size());
iposva@chromium.org245aa852009-02-10 00:49:54 +0000187 } else {
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000188 LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG,
189 *code, ""));
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000190 OProfileAgent::CreateNativeCodeRegion(is_eval ? "Eval" : "Script",
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000191 code->instruction_start(),
192 code->instruction_size());
iposva@chromium.org245aa852009-02-10 00:49:54 +0000193 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000194 }
iposva@chromium.org245aa852009-02-10 00:49:54 +0000195#endif
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000196
197 // Allocate function.
198 Handle<JSFunction> fun =
199 Factory::NewFunctionBoilerplate(lit->name(),
200 lit->materialized_literal_count(),
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000201 lit->contains_array_literal(),
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000202 code);
203
204 CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(),
ager@chromium.org236ad962008-09-25 09:45:57 +0000205 RelocInfo::kNoPosition,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000206 lit->start_position(), lit->end_position(),
kasperl@chromium.orgd1e3e722009-04-14 13:38:25 +0000207 lit->is_expression(), true, script,
208 lit->inferred_name());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000209
210 // Hint to the runtime system used when allocating space for initial
211 // property space by setting the expected number of properties for
212 // the instances of the function.
213 SetExpectedNofPropertiesFromEstimate(fun, lit->expected_property_count());
214
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000215#ifdef ENABLE_DEBUGGER_SUPPORT
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000216 // Notify debugger
217 Debugger::OnAfterCompile(script, fun);
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000218#endif
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000219
220 return fun;
221}
222
223
224static StaticResource<SafeStringInputBuffer> safe_string_input_buffer;
225
226
227Handle<JSFunction> Compiler::Compile(Handle<String> source,
mads.s.agercbaa0602008-08-14 13:41:48 +0000228 Handle<Object> script_name,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000229 int line_offset, int column_offset,
230 v8::Extension* extension,
231 ScriptDataImpl* input_pre_data) {
ager@chromium.org870a0b62008-11-04 11:43:05 +0000232 int source_length = source->length();
233 Counters::total_load_size.Increment(source_length);
234 Counters::total_compile_size.Increment(source_length);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000235
236 // The VM is in the COMPILER state until exiting this function.
237 VMState state(COMPILER);
238
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000239 // Do a lookup in the compilation cache but not for extensions.
240 Handle<JSFunction> result;
241 if (extension == NULL) {
242 result = CompilationCache::LookupScript(source,
243 script_name,
244 line_offset,
245 column_offset);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000246 }
247
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000248 if (result.is_null()) {
249 // No cache entry found. Do pre-parsing and compile the script.
250 ScriptDataImpl* pre_data = input_pre_data;
ager@chromium.org870a0b62008-11-04 11:43:05 +0000251 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) {
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000252 Access<SafeStringInputBuffer> buf(&safe_string_input_buffer);
253 buf->Reset(source.location());
254 pre_data = PreParse(buf.value(), extension);
255 }
256
257 // Create a script object describing the script to be compiled.
258 Handle<Script> script = Factory::NewScript(source);
259 if (!script_name.is_null()) {
260 script->set_name(*script_name);
261 script->set_line_offset(Smi::FromInt(line_offset));
262 script->set_column_offset(Smi::FromInt(column_offset));
263 }
264
265 // Compile the function and add it to the cache.
ager@chromium.org381abbb2009-02-25 13:23:22 +0000266 result = MakeFunction(true,
267 false,
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000268 false,
ager@chromium.org381abbb2009-02-25 13:23:22 +0000269 script,
270 Handle<Context>::null(),
271 extension,
272 pre_data);
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000273 if (extension == NULL && !result.is_null()) {
kasperl@chromium.org8ccb0be2009-04-07 07:21:39 +0000274 CompilationCache::PutScript(source, result);
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000275 }
276
277 // Get rid of the pre-parsing data (if necessary).
278 if (input_pre_data == NULL && pre_data != NULL) {
279 delete pre_data;
280 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000281 }
282
ager@chromium.org8bb60582008-12-11 12:02:20 +0000283 if (result.is_null()) Top::ReportPendingMessages();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000284 return result;
285}
286
287
ager@chromium.org236ad962008-09-25 09:45:57 +0000288Handle<JSFunction> Compiler::CompileEval(Handle<String> source,
ager@chromium.org381abbb2009-02-25 13:23:22 +0000289 Handle<Context> context,
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000290 bool is_global,
291 bool is_json) {
ager@chromium.orgc3e50d82008-11-05 11:53:10 +0000292 int source_length = source->length();
ager@chromium.org870a0b62008-11-04 11:43:05 +0000293 Counters::total_eval_size.Increment(source_length);
294 Counters::total_compile_size.Increment(source_length);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000295
296 // The VM is in the COMPILER state until exiting this function.
297 VMState state(COMPILER);
298
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000299 // Do a lookup in the compilation cache; if the entry is not there,
300 // invoke the compiler and add the result to the cache.
ager@chromium.org381abbb2009-02-25 13:23:22 +0000301 Handle<JSFunction> result =
ager@chromium.org5aa501c2009-06-23 07:57:28 +0000302 CompilationCache::LookupEval(source, context, is_global);
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000303 if (result.is_null()) {
304 // Create a script object describing the script to be compiled.
305 Handle<Script> script = Factory::NewScript(source);
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000306 result = MakeFunction(is_global,
307 true,
308 is_json,
309 script,
310 context,
311 NULL,
312 NULL);
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000313 if (!result.is_null()) {
ager@chromium.org5aa501c2009-06-23 07:57:28 +0000314 CompilationCache::PutEval(source, context, is_global, result);
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000315 }
316 }
ager@chromium.org8bb60582008-12-11 12:02:20 +0000317
kasperl@chromium.orgb9123622008-09-17 14:05:56 +0000318 return result;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000319}
320
321
ager@chromium.org3bf7b912008-11-17 09:09:45 +0000322bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared,
323 int loop_nesting) {
kasperl@chromium.orgb3284ad2009-05-18 06:12:45 +0000324 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000325
326 // The VM is in the COMPILER state until exiting this function.
327 VMState state(COMPILER);
328
329 // Make sure we have an initial stack limit.
330 StackGuard guard;
kasper.lund44510672008-07-25 07:37:58 +0000331 PostponeInterruptsScope postpone;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000332
333 // Compute name, source code and script data.
334 Handle<String> name(String::cast(shared->name()));
335 Handle<Script> script(Script::cast(shared->script()));
336
337 int start_position = shared->start_position();
338 int end_position = shared->end_position();
339 bool is_expression = shared->is_expression();
340 Counters::total_compile_size.Increment(end_position - start_position);
341
342 // Generate the AST for the lazily compiled function. The AST may be
343 // NULL in case of parser stack overflow.
344 FunctionLiteral* lit = MakeLazyAST(script, name,
345 start_position,
346 end_position,
347 is_expression);
348
kasper.lund212ac232008-07-16 07:07:30 +0000349 // Check for parse errors.
350 if (lit == NULL) {
351 ASSERT(Top::has_pending_exception());
kasper.lund212ac232008-07-16 07:07:30 +0000352 return false;
353 }
354
ager@chromium.org3bf7b912008-11-17 09:09:45 +0000355 // Update the loop nesting in the function literal.
356 lit->set_loop_nesting(loop_nesting);
357
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000358 // Measure how long it takes to do the lazy compilation; only take
359 // the rest of the function into account to avoid overlap with the
360 // lazy parsing statistics.
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000361 HistogramTimerScope timer(&Counters::compile_lazy);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000362
kasper.lund212ac232008-07-16 07:07:30 +0000363 // Compile the code.
ager@chromium.org381abbb2009-02-25 13:23:22 +0000364 Handle<Code> code = MakeCode(lit, script, Handle<Context>::null(), false);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000365
kasper.lund212ac232008-07-16 07:07:30 +0000366 // Check for stack-overflow exception.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000367 if (code.is_null()) {
kasper.lund212ac232008-07-16 07:07:30 +0000368 Top::StackOverflow();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000369 return false;
370 }
371
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000372#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT
iposva@chromium.org245aa852009-02-10 00:49:54 +0000373 // Log the code generation. If source information is available include script
374 // name and line number. Check explicit whether logging is enabled as finding
375 // the line number is not for free.
ager@chromium.org3e875802009-06-29 08:26:34 +0000376 if (Logger::is_logging() || OProfileAgent::is_enabled()) {
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000377 Handle<String> func_name(name->length() > 0 ?
378 *name : shared->inferred_name());
iposva@chromium.org245aa852009-02-10 00:49:54 +0000379 if (script->name()->IsString()) {
ager@chromium.org5aa501c2009-06-23 07:57:28 +0000380 int line_num = GetScriptLineNumber(script, start_position) + 1;
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000381 LOG(CodeCreateEvent(Logger::LAZY_COMPILE_TAG, *code, *func_name,
iposva@chromium.org245aa852009-02-10 00:49:54 +0000382 String::cast(script->name()), line_num));
kasperl@chromium.orgd1e3e722009-04-14 13:38:25 +0000383 OProfileAgent::CreateNativeCodeRegion(*func_name,
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000384 String::cast(script->name()),
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000385 line_num,
386 code->instruction_start(),
387 code->instruction_size());
iposva@chromium.org245aa852009-02-10 00:49:54 +0000388 } else {
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000389 LOG(CodeCreateEvent(Logger::LAZY_COMPILE_TAG, *code, *func_name));
390 OProfileAgent::CreateNativeCodeRegion(*func_name,
391 code->instruction_start(),
392 code->instruction_size());
iposva@chromium.org245aa852009-02-10 00:49:54 +0000393 }
394 }
395#endif
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000396
397 // Update the shared function info with the compiled code.
398 shared->set_code(*code);
399
400 // Set the expected number of properties for instances.
401 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
402
403 // Check the function has compiled code.
404 ASSERT(shared->is_compiled());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000405 return true;
406}
407
408
409} } // namespace v8::internal