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

Side by Side Diff: src/compiler.cc

Issue 2867013: [Isolates] CompilationCache was moved to Isolate. (Closed) Base URL: git@github.com:v8isolate/v8isolates.git
Patch Set: Created 10 years, 6 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
« no previous file with comments | « src/compilation-cache.cc ('k') | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 ScriptDataImpl* input_pre_data, 286 ScriptDataImpl* input_pre_data,
287 Handle<Object> script_data, 287 Handle<Object> script_data,
288 NativesFlag natives) { 288 NativesFlag natives) {
289 int source_length = source->length(); 289 int source_length = source->length();
290 Counters::total_load_size.Increment(source_length); 290 Counters::total_load_size.Increment(source_length);
291 Counters::total_compile_size.Increment(source_length); 291 Counters::total_compile_size.Increment(source_length);
292 292
293 // The VM is in the COMPILER state until exiting this function. 293 // The VM is in the COMPILER state until exiting this function.
294 VMState state(COMPILER); 294 VMState state(COMPILER);
295 295
296 CompilationCache* compilation_cache = Isolate::Current()->compilation_cache();
297
296 // Do a lookup in the compilation cache but not for extensions. 298 // Do a lookup in the compilation cache but not for extensions.
297 Handle<SharedFunctionInfo> result; 299 Handle<SharedFunctionInfo> result;
298 if (extension == NULL) { 300 if (extension == NULL) {
299 result = CompilationCache::LookupScript(source, 301 result = compilation_cache->LookupScript(source,
300 script_name, 302 script_name,
301 line_offset, 303 line_offset,
302 column_offset); 304 column_offset);
303 } 305 }
304 306
305 if (result.is_null()) { 307 if (result.is_null()) {
306 // No cache entry found. Do pre-parsing and compile the script. 308 // No cache entry found. Do pre-parsing and compile the script.
307 ScriptDataImpl* pre_data = input_pre_data; 309 ScriptDataImpl* pre_data = input_pre_data;
308 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) { 310 if (pre_data == NULL && source_length >= FLAG_min_preparse_length) {
309 Access<SafeStringInputBuffer> buf(&safe_string_input_buffer); 311 Access<SafeStringInputBuffer> buf(&safe_string_input_buffer);
310 buf->Reset(source.location()); 312 buf->Reset(source.location());
311 pre_data = PreParse(source, buf.value(), extension); 313 pre_data = PreParse(source, buf.value(), extension);
312 } 314 }
(...skipping 14 matching lines...) Expand all
327 329
328 // Compile the function and add it to the cache. 330 // Compile the function and add it to the cache.
329 result = MakeFunctionInfo(true, 331 result = MakeFunctionInfo(true,
330 false, 332 false,
331 DONT_VALIDATE_JSON, 333 DONT_VALIDATE_JSON,
332 script, 334 script,
333 Handle<Context>::null(), 335 Handle<Context>::null(),
334 extension, 336 extension,
335 pre_data); 337 pre_data);
336 if (extension == NULL && !result.is_null()) { 338 if (extension == NULL && !result.is_null()) {
337 CompilationCache::PutScript(source, result); 339 compilation_cache->PutScript(source, result);
338 } 340 }
339 341
340 // Get rid of the pre-parsing data (if necessary). 342 // Get rid of the pre-parsing data (if necessary).
341 if (input_pre_data == NULL && pre_data != NULL) { 343 if (input_pre_data == NULL && pre_data != NULL) {
342 delete pre_data; 344 delete pre_data;
343 } 345 }
344 } 346 }
345 347
346 if (result.is_null()) Top::ReportPendingMessages(); 348 if (result.is_null()) Top::ReportPendingMessages();
347 return result; 349 return result;
348 } 350 }
349 351
350 352
351 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, 353 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
352 Handle<Context> context, 354 Handle<Context> context,
353 bool is_global, 355 bool is_global,
354 ValidationState validate) { 356 ValidationState validate) {
355 // Note that if validation is required then no path through this 357 // Note that if validation is required then no path through this
356 // function is allowed to return a value without validating that 358 // function is allowed to return a value without validating that
357 // the input is legal json. 359 // the input is legal json.
358 360
359 int source_length = source->length(); 361 int source_length = source->length();
360 Counters::total_eval_size.Increment(source_length); 362 Counters::total_eval_size.Increment(source_length);
361 Counters::total_compile_size.Increment(source_length); 363 Counters::total_compile_size.Increment(source_length);
362 364
363 // The VM is in the COMPILER state until exiting this function. 365 // The VM is in the COMPILER state until exiting this function.
364 VMState state(COMPILER); 366 VMState state(COMPILER);
365 367
368 CompilationCache* compilation_cache = Isolate::Current()->compilation_cache();
369
366 // Do a lookup in the compilation cache; if the entry is not there, 370 // Do a lookup in the compilation cache; if the entry is not there,
367 // invoke the compiler and add the result to the cache. If we're 371 // invoke the compiler and add the result to the cache. If we're
368 // evaluating json we bypass the cache since we can't be sure a 372 // evaluating json we bypass the cache since we can't be sure a
369 // potential value in the cache has been validated. 373 // potential value in the cache has been validated.
370 Handle<SharedFunctionInfo> result; 374 Handle<SharedFunctionInfo> result;
371 if (validate == DONT_VALIDATE_JSON) 375 if (validate == DONT_VALIDATE_JSON)
372 result = CompilationCache::LookupEval(source, context, is_global); 376 result = compilation_cache->LookupEval(source, context, is_global);
373 377
374 if (result.is_null()) { 378 if (result.is_null()) {
375 // Create a script object describing the script to be compiled. 379 // Create a script object describing the script to be compiled.
376 Handle<Script> script = Factory::NewScript(source); 380 Handle<Script> script = Factory::NewScript(source);
377 result = MakeFunctionInfo(is_global, 381 result = MakeFunctionInfo(is_global,
378 true, 382 true,
379 validate, 383 validate,
380 script, 384 script,
381 context, 385 context,
382 NULL, 386 NULL,
383 NULL); 387 NULL);
384 if (!result.is_null() && validate != VALIDATE_JSON) { 388 if (!result.is_null() && validate != VALIDATE_JSON) {
385 // For json it's unlikely that we'll ever see exactly the same 389 // For json it's unlikely that we'll ever see exactly the same
386 // string again so we don't use the compilation cache. 390 // string again so we don't use the compilation cache.
387 CompilationCache::PutEval(source, context, is_global, result); 391 compilation_cache->PutEval(source, context, is_global, result);
388 } 392 }
389 } 393 }
390 394
391 return result; 395 return result;
392 } 396 }
393 397
394 398
395 bool Compiler::CompileLazy(CompilationInfo* info) { 399 bool Compiler::CompileLazy(CompilationInfo* info) {
396 CompilationZoneScope zone_scope(DELETE_ON_EXIT); 400 CompilationZoneScope zone_scope(DELETE_ON_EXIT);
397 401
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 637 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
634 *code, *func_name)); 638 *code, *func_name));
635 OPROFILE(CreateNativeCodeRegion(*func_name, 639 OPROFILE(CreateNativeCodeRegion(*func_name,
636 code->instruction_start(), 640 code->instruction_start(),
637 code->instruction_size())); 641 code->instruction_size()));
638 } 642 }
639 } 643 }
640 } 644 }
641 645
642 } } // namespace v8::internal 646 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698