| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 v8::Extension* extension, | 258 v8::Extension* extension, |
| 259 ScriptDataImpl* input_pre_data, | 259 ScriptDataImpl* input_pre_data, |
| 260 Handle<Object> script_data, | 260 Handle<Object> script_data, |
| 261 NativesFlag natives) { | 261 NativesFlag natives) { |
| 262 Isolate* isolate = Isolate::Current(); | 262 Isolate* isolate = Isolate::Current(); |
| 263 int source_length = source->length(); | 263 int source_length = source->length(); |
| 264 COUNTERS->total_load_size()->Increment(source_length); | 264 COUNTERS->total_load_size()->Increment(source_length); |
| 265 COUNTERS->total_compile_size()->Increment(source_length); | 265 COUNTERS->total_compile_size()->Increment(source_length); |
| 266 | 266 |
| 267 // The VM is in the COMPILER state until exiting this function. | 267 // The VM is in the COMPILER state until exiting this function. |
| 268 VMState state(COMPILER); | 268 VMState state(isolate, COMPILER); |
| 269 | 269 |
| 270 CompilationCache* compilation_cache = isolate->compilation_cache(); | 270 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 271 | 271 |
| 272 // Do a lookup in the compilation cache but not for extensions. | 272 // Do a lookup in the compilation cache but not for extensions. |
| 273 Handle<SharedFunctionInfo> result; | 273 Handle<SharedFunctionInfo> result; |
| 274 if (extension == NULL) { | 274 if (extension == NULL) { |
| 275 result = compilation_cache->LookupScript(source, | 275 result = compilation_cache->LookupScript(source, |
| 276 script_name, | 276 script_name, |
| 277 line_offset, | 277 line_offset, |
| 278 column_offset); | 278 column_offset); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 | 325 |
| 326 if (result.is_null()) isolate->ReportPendingMessages(); | 326 if (result.is_null()) isolate->ReportPendingMessages(); |
| 327 return result; | 327 return result; |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, | 331 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, |
| 332 Handle<Context> context, | 332 Handle<Context> context, |
| 333 bool is_global) { | 333 bool is_global) { |
| 334 Isolate* isolate = source->GetIsolate(); |
| 334 int source_length = source->length(); | 335 int source_length = source->length(); |
| 335 COUNTERS->total_eval_size()->Increment(source_length); | 336 isolate->counters()->total_eval_size()->Increment(source_length); |
| 336 COUNTERS->total_compile_size()->Increment(source_length); | 337 isolate->counters()->total_compile_size()->Increment(source_length); |
| 337 | 338 |
| 338 // The VM is in the COMPILER state until exiting this function. | 339 // The VM is in the COMPILER state until exiting this function. |
| 339 VMState state(COMPILER); | 340 VMState state(isolate, COMPILER); |
| 340 | 341 |
| 341 // Do a lookup in the compilation cache; if the entry is not there, invoke | 342 // Do a lookup in the compilation cache; if the entry is not there, invoke |
| 342 // the compiler and add the result to the cache. | 343 // the compiler and add the result to the cache. |
| 343 Handle<SharedFunctionInfo> result; | 344 Handle<SharedFunctionInfo> result; |
| 344 CompilationCache* compilation_cache = | 345 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 345 context->GetIsolate()->compilation_cache(); | |
| 346 result = compilation_cache->LookupEval(source, context, is_global); | 346 result = compilation_cache->LookupEval(source, context, is_global); |
| 347 | 347 |
| 348 if (result.is_null()) { | 348 if (result.is_null()) { |
| 349 // Create a script object describing the script to be compiled. | 349 // Create a script object describing the script to be compiled. |
| 350 Handle<Script> script = FACTORY->NewScript(source); | 350 Handle<Script> script = isolate->factory()->NewScript(source); |
| 351 CompilationInfo info(script); | 351 CompilationInfo info(script); |
| 352 info.MarkAsEval(); | 352 info.MarkAsEval(); |
| 353 if (is_global) info.MarkAsGlobal(); | 353 if (is_global) info.MarkAsGlobal(); |
| 354 info.SetCallingContext(context); | 354 info.SetCallingContext(context); |
| 355 result = MakeFunctionInfo(&info); | 355 result = MakeFunctionInfo(&info); |
| 356 if (!result.is_null()) { | 356 if (!result.is_null()) { |
| 357 CompilationCache* compilation_cache = | 357 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 358 context->GetIsolate()->compilation_cache(); | |
| 359 compilation_cache->PutEval(source, context, is_global, result); | 358 compilation_cache->PutEval(source, context, is_global, result); |
| 360 } | 359 } |
| 361 } | 360 } |
| 362 | 361 |
| 363 return result; | 362 return result; |
| 364 } | 363 } |
| 365 | 364 |
| 366 | 365 |
| 367 bool Compiler::CompileLazy(CompilationInfo* info) { | 366 bool Compiler::CompileLazy(CompilationInfo* info) { |
| 368 CompilationZoneScope zone_scope(DELETE_ON_EXIT); | 367 CompilationZoneScope zone_scope(DELETE_ON_EXIT); |
| 369 | 368 |
| 370 // The VM is in the COMPILER state until exiting this function. | 369 // The VM is in the COMPILER state until exiting this function. |
| 371 VMState state(COMPILER); | 370 VMState state(info->isolate(), COMPILER); |
| 372 | 371 |
| 373 PostponeInterruptsScope postpone; | 372 PostponeInterruptsScope postpone; |
| 374 | 373 |
| 375 Handle<SharedFunctionInfo> shared = info->shared_info(); | 374 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 376 int compiled_size = shared->end_position() - shared->start_position(); | 375 int compiled_size = shared->end_position() - shared->start_position(); |
| 377 info->isolate()->counters()->total_compile_size()->Increment(compiled_size); | 376 info->isolate()->counters()->total_compile_size()->Increment(compiled_size); |
| 378 | 377 |
| 379 // Generate the AST for the lazily compiled function. | 378 // Generate the AST for the lazily compiled function. |
| 380 if (ParserApi::Parse(info)) { | 379 if (ParserApi::Parse(info)) { |
| 381 // Measure how long it takes to do the lazy compilation; only take the | 380 // Measure how long it takes to do the lazy compilation; only take the |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 *code, | 563 *code, |
| 565 *name)); | 564 *name)); |
| 566 OPROFILE(CreateNativeCodeRegion(*name, | 565 OPROFILE(CreateNativeCodeRegion(*name, |
| 567 code->instruction_start(), | 566 code->instruction_start(), |
| 568 code->instruction_size())); | 567 code->instruction_size())); |
| 569 } | 568 } |
| 570 } | 569 } |
| 571 } | 570 } |
| 572 | 571 |
| 573 } } // namespace v8::internal | 572 } } // namespace v8::internal |
| OLD | NEW |