OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/background-parsing-task.h" | 5 #include "src/background-parsing-task.h" |
6 #include "src/debug/debug.h" | 6 #include "src/debug/debug.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 DisallowHandleAllocation no_handles; | 42 DisallowHandleAllocation no_handles; |
43 DisallowHandleDereference no_deref; | 43 DisallowHandleDereference no_deref; |
44 | 44 |
45 ScriptData* script_data = NULL; | 45 ScriptData* script_data = NULL; |
46 ScriptCompiler::CompileOptions options = source_->info->compile_options(); | 46 ScriptCompiler::CompileOptions options = source_->info->compile_options(); |
47 if (options == ScriptCompiler::kProduceParserCache || | 47 if (options == ScriptCompiler::kProduceParserCache || |
48 options == ScriptCompiler::kProduceCodeCache) { | 48 options == ScriptCompiler::kProduceCodeCache) { |
49 source_->info->set_cached_data(&script_data); | 49 source_->info->set_cached_data(&script_data); |
50 } | 50 } |
51 | 51 |
| 52 // Nullify the Isolate temporarily so that the background parser doesn't |
| 53 // accidentally use it. |
| 54 Isolate* isolate = source_->info->isolate(); |
| 55 source_->info->set_isolate(nullptr); |
| 56 |
52 uintptr_t stack_limit = | 57 uintptr_t stack_limit = |
53 reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB; | 58 reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB; |
54 | 59 |
55 source_->info->set_stack_limit(stack_limit); | 60 source_->info->set_stack_limit(stack_limit); |
56 // Parser needs to stay alive for finalizing the parsing on the main | 61 // Parser needs to stay alive for finalizing the parsing on the main |
57 // thread. Passing &parse_info is OK because Parser doesn't store it. | 62 // thread. Passing &parse_info is OK because Parser doesn't store it. |
58 source_->parser.reset(new Parser(source_->info.get())); | 63 source_->parser.reset(new Parser(source_->info.get())); |
59 source_->parser->ParseOnBackground(source_->info.get()); | 64 source_->parser->ParseOnBackground(source_->info.get()); |
60 | 65 |
61 if (script_data != NULL) { | 66 if (script_data != NULL) { |
62 source_->cached_data.reset(new ScriptCompiler::CachedData( | 67 source_->cached_data.reset(new ScriptCompiler::CachedData( |
63 script_data->data(), script_data->length(), | 68 script_data->data(), script_data->length(), |
64 ScriptCompiler::CachedData::BufferOwned)); | 69 ScriptCompiler::CachedData::BufferOwned)); |
65 script_data->ReleaseDataOwnership(); | 70 script_data->ReleaseDataOwnership(); |
66 delete script_data; | 71 delete script_data; |
67 } | 72 } |
| 73 source_->info->set_isolate(isolate); |
68 } | 74 } |
69 } // namespace internal | 75 } // namespace internal |
70 } // namespace v8 | 76 } // namespace v8 |
OLD | NEW |