Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: src/compiler.cc

Issue 1052003: Keep more track of whether code is from the built... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler.h ('k') | src/debug.cc » ('j') | src/globals.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 272
273 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; 273 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer;
274 274
275 275
276 Handle<JSFunction> Compiler::Compile(Handle<String> source, 276 Handle<JSFunction> Compiler::Compile(Handle<String> source,
277 Handle<Object> script_name, 277 Handle<Object> script_name,
278 int line_offset, int column_offset, 278 int line_offset, int column_offset,
279 v8::Extension* extension, 279 v8::Extension* extension,
280 ScriptDataImpl* input_pre_data, 280 ScriptDataImpl* input_pre_data,
281 Handle<Object> script_data) { 281 Handle<Object> script_data,
282 NativesFlag natives) {
282 int source_length = source->length(); 283 int source_length = source->length();
283 Counters::total_load_size.Increment(source_length); 284 Counters::total_load_size.Increment(source_length);
284 Counters::total_compile_size.Increment(source_length); 285 Counters::total_compile_size.Increment(source_length);
285 286
286 // The VM is in the COMPILER state until exiting this function. 287 // The VM is in the COMPILER state until exiting this function.
287 VMState state(COMPILER); 288 VMState state(COMPILER);
288 289
289 // Do a lookup in the compilation cache but not for extensions. 290 // Do a lookup in the compilation cache but not for extensions.
290 Handle<JSFunction> result; 291 Handle<JSFunction> result;
291 if (extension == NULL) { 292 if (extension == NULL) {
292 result = CompilationCache::LookupScript(source, 293 result = CompilationCache::LookupScript(source,
293 script_name, 294 script_name,
294 line_offset, 295 line_offset,
295 column_offset); 296 column_offset);
296 } 297 }
297 298
298 if (result.is_null()) { 299 if (result.is_null()) {
299 // No cache entry found. Do pre-parsing and compile the script. 300 // No cache entry found. Do pre-parsing and compile the script.
300 ScriptDataImpl* pre_data = input_pre_data; 301 ScriptDataImpl* pre_data = input_pre_data;
301 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) { 302 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) {
302 Access<SafeStringInputBuffer> buf(&safe_string_input_buffer); 303 Access<SafeStringInputBuffer> buf(&safe_string_input_buffer);
303 buf->Reset(source.location()); 304 buf->Reset(source.location());
304 pre_data = PreParse(source, buf.value(), extension); 305 pre_data = PreParse(source, buf.value(), extension);
305 } 306 }
306 307
307 // Create a script object describing the script to be compiled. 308 // Create a script object describing the script to be compiled.
308 Handle<Script> script = Factory::NewScript(source); 309 Handle<Script> script = Factory::NewScript(source);
310 if (natives == NATIVES_CODE) {
311 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
312 }
309 if (!script_name.is_null()) { 313 if (!script_name.is_null()) {
310 script->set_name(*script_name); 314 script->set_name(*script_name);
311 script->set_line_offset(Smi::FromInt(line_offset)); 315 script->set_line_offset(Smi::FromInt(line_offset));
312 script->set_column_offset(Smi::FromInt(column_offset)); 316 script->set_column_offset(Smi::FromInt(column_offset));
313 } 317 }
314 318
315 script->set_data(script_data.is_null() ? Heap::undefined_value() 319 script->set_data(script_data.is_null() ? Heap::undefined_value()
316 : *script_data); 320 : *script_data);
317 321
318 // Compile the function and add it to the cache. 322 // Compile the function and add it to the cache.
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 LOG(CodeCreateEvent(tag, *code, *func_name)); 637 LOG(CodeCreateEvent(tag, *code, *func_name));
634 OProfileAgent::CreateNativeCodeRegion(*func_name, 638 OProfileAgent::CreateNativeCodeRegion(*func_name,
635 code->instruction_start(), 639 code->instruction_start(),
636 code->instruction_size()); 640 code->instruction_size());
637 } 641 }
638 } 642 }
639 } 643 }
640 #endif 644 #endif
641 645
642 } } // namespace v8::internal 646 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/debug.cc » ('j') | src/globals.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698