| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 526 } |
| 527 | 527 |
| 528 if (result.is_null()) isolate->ReportPendingMessages(); | 528 if (result.is_null()) isolate->ReportPendingMessages(); |
| 529 return result; | 529 return result; |
| 530 } | 530 } |
| 531 | 531 |
| 532 | 532 |
| 533 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, | 533 Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, |
| 534 Handle<Context> context, | 534 Handle<Context> context, |
| 535 bool is_global, | 535 bool is_global, |
| 536 StrictModeFlag strict_mode) { | 536 StrictModeFlag strict_mode, |
| 537 int scope_position) { |
| 537 Isolate* isolate = source->GetIsolate(); | 538 Isolate* isolate = source->GetIsolate(); |
| 538 int source_length = source->length(); | 539 int source_length = source->length(); |
| 539 isolate->counters()->total_eval_size()->Increment(source_length); | 540 isolate->counters()->total_eval_size()->Increment(source_length); |
| 540 isolate->counters()->total_compile_size()->Increment(source_length); | 541 isolate->counters()->total_compile_size()->Increment(source_length); |
| 541 | 542 |
| 542 // The VM is in the COMPILER state until exiting this function. | 543 // The VM is in the COMPILER state until exiting this function. |
| 543 VMState state(isolate, COMPILER); | 544 VMState state(isolate, COMPILER); |
| 544 | 545 |
| 545 // Do a lookup in the compilation cache; if the entry is not there, invoke | 546 // Do a lookup in the compilation cache; if the entry is not there, invoke |
| 546 // the compiler and add the result to the cache. | 547 // the compiler and add the result to the cache. |
| 547 Handle<SharedFunctionInfo> result; | 548 Handle<SharedFunctionInfo> result; |
| 548 CompilationCache* compilation_cache = isolate->compilation_cache(); | 549 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 549 result = compilation_cache->LookupEval(source, | 550 result = compilation_cache->LookupEval(source, |
| 550 context, | 551 context, |
| 551 is_global, | 552 is_global, |
| 552 strict_mode); | 553 strict_mode, |
| 554 scope_position); |
| 553 | 555 |
| 554 if (result.is_null()) { | 556 if (result.is_null()) { |
| 555 // Create a script object describing the script to be compiled. | 557 // Create a script object describing the script to be compiled. |
| 556 Handle<Script> script = isolate->factory()->NewScript(source); | 558 Handle<Script> script = isolate->factory()->NewScript(source); |
| 557 CompilationInfo info(script); | 559 CompilationInfo info(script); |
| 558 info.MarkAsEval(); | 560 info.MarkAsEval(); |
| 559 if (is_global) info.MarkAsGlobal(); | 561 if (is_global) info.MarkAsGlobal(); |
| 560 info.SetStrictModeFlag(strict_mode); | 562 info.SetStrictModeFlag(strict_mode); |
| 561 info.SetCallingContext(context); | 563 info.SetCallingContext(context); |
| 562 result = MakeFunctionInfo(&info); | 564 result = MakeFunctionInfo(&info); |
| 563 if (!result.is_null()) { | 565 if (!result.is_null()) { |
| 564 CompilationCache* compilation_cache = isolate->compilation_cache(); | |
| 565 // If caller is strict mode, the result must be strict as well, | 566 // If caller is strict mode, the result must be strict as well, |
| 566 // but not the other way around. Consider: | 567 // but not the other way around. Consider: |
| 567 // eval("'use strict'; ..."); | 568 // eval("'use strict'; ..."); |
| 568 // TODO(keuchel): adapt this for extended mode. | 569 // TODO(keuchel): adapt this for extended mode. |
| 569 ASSERT(strict_mode == kNonStrictMode || result->strict_mode()); | 570 ASSERT(strict_mode == kNonStrictMode || result->strict_mode()); |
| 570 compilation_cache->PutEval(source, context, is_global, result); | 571 compilation_cache->PutEval( |
| 572 source, context, is_global, result, scope_position); |
| 571 } | 573 } |
| 572 } | 574 } |
| 573 | 575 |
| 574 return result; | 576 return result; |
| 575 } | 577 } |
| 576 | 578 |
| 577 | 579 |
| 578 bool Compiler::CompileLazy(CompilationInfo* info) { | 580 bool Compiler::CompileLazy(CompilationInfo* info) { |
| 579 Isolate* isolate = info->isolate(); | 581 Isolate* isolate = info->isolate(); |
| 580 | 582 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 } | 789 } |
| 788 } | 790 } |
| 789 | 791 |
| 790 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 792 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 791 Handle<Script>(info->script()), | 793 Handle<Script>(info->script()), |
| 792 Handle<Code>(info->code()), | 794 Handle<Code>(info->code()), |
| 793 info)); | 795 info)); |
| 794 } | 796 } |
| 795 | 797 |
| 796 } } // namespace v8::internal | 798 } } // namespace v8::internal |
| OLD | NEW |