OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 void V8::SetNativesDataBlob(StartupData* natives_blob) { | 200 void V8::SetNativesDataBlob(StartupData* natives_blob) { |
201 i::V8::SetNativesBlob(natives_blob); | 201 i::V8::SetNativesBlob(natives_blob); |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { | 205 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { |
206 i::V8::SetSnapshotBlob(snapshot_blob); | 206 i::V8::SetSnapshotBlob(snapshot_blob); |
207 } | 207 } |
208 | 208 |
209 | 209 |
210 bool RunExtraCode(Isolate* isolate, char* utf8_source) { | 210 bool RunExtraCode(Isolate* isolate, const char* utf8_source) { |
211 // Run custom script if provided. | 211 // Run custom script if provided. |
212 TryCatch try_catch; | 212 TryCatch try_catch; |
213 Local<String> source_string = String::NewFromUtf8(isolate, utf8_source); | 213 Local<String> source_string = String::NewFromUtf8(isolate, utf8_source); |
214 if (try_catch.HasCaught()) return false; | 214 if (try_catch.HasCaught()) return false; |
215 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); | 215 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); |
216 ScriptCompiler::Source source(source_string, origin); | 216 ScriptCompiler::Source source(source_string, origin); |
217 Local<Script> script = ScriptCompiler::Compile(isolate, &source); | 217 Local<Script> script = ScriptCompiler::Compile(isolate, &source); |
218 if (try_catch.HasCaught()) return false; | 218 if (try_catch.HasCaught()) return false; |
219 script->Run(); | 219 script->Run(); |
220 return !try_catch.HasCaught(); | 220 return !try_catch.HasCaught(); |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 StartupData V8::CreateSnapshotDataBlob(char* custom_source) { | 224 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) { |
225 Isolate::CreateParams params; | 225 Isolate::CreateParams params; |
226 params.enable_serializer = true; | 226 params.enable_serializer = true; |
227 Isolate* isolate = v8::Isolate::New(params); | 227 Isolate* isolate = v8::Isolate::New(params); |
228 StartupData result = {NULL, 0}; | 228 StartupData result = {NULL, 0}; |
229 { | 229 { |
230 Isolate::Scope isolate_scope(isolate); | 230 Isolate::Scope isolate_scope(isolate); |
231 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 231 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
232 Persistent<Context> context; | 232 Persistent<Context> context; |
233 i::Snapshot::Metadata metadata; | 233 i::Snapshot::Metadata metadata; |
234 { | 234 { |
(...skipping 6284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6519 | 6519 |
6520 Isolate* Isolate::GetCurrent() { | 6520 Isolate* Isolate::GetCurrent() { |
6521 i::Isolate* isolate = i::Isolate::Current(); | 6521 i::Isolate* isolate = i::Isolate::Current(); |
6522 return reinterpret_cast<Isolate*>(isolate); | 6522 return reinterpret_cast<Isolate*>(isolate); |
6523 } | 6523 } |
6524 | 6524 |
6525 | 6525 |
6526 Isolate* Isolate::New(const Isolate::CreateParams& params) { | 6526 Isolate* Isolate::New(const Isolate::CreateParams& params) { |
6527 i::Isolate* isolate = new i::Isolate(params.enable_serializer); | 6527 i::Isolate* isolate = new i::Isolate(params.enable_serializer); |
6528 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); | 6528 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
6529 if (!params.enable_serializer) { | |
vogelheim
2015/02/24 15:16:31
Why the check for !enable_serializer?
The comment
Yang
2015/02/25 08:19:20
You are right. In fact, there is no point in havin
| |
6530 if (params.snapshot_blob != NULL) { | |
6531 isolate->set_snapshot_blob(params.snapshot_blob); | |
6532 } else { | |
6533 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); | |
6534 } | |
6535 } | |
6529 if (params.entry_hook) { | 6536 if (params.entry_hook) { |
6530 isolate->set_function_entry_hook(params.entry_hook); | 6537 isolate->set_function_entry_hook(params.entry_hook); |
6531 } | 6538 } |
6532 if (params.code_event_handler) { | 6539 if (params.code_event_handler) { |
6533 isolate->InitializeLoggingAndCounters(); | 6540 isolate->InitializeLoggingAndCounters(); |
6534 isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault, | 6541 isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault, |
6535 params.code_event_handler); | 6542 params.code_event_handler); |
6536 } | 6543 } |
6537 SetResourceConstraints(isolate, params.constraints); | 6544 SetResourceConstraints(isolate, params.constraints); |
6538 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. | 6545 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7783 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7790 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7784 Address callback_address = | 7791 Address callback_address = |
7785 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7792 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7786 VMState<EXTERNAL> state(isolate); | 7793 VMState<EXTERNAL> state(isolate); |
7787 ExternalCallbackScope call_scope(isolate, callback_address); | 7794 ExternalCallbackScope call_scope(isolate, callback_address); |
7788 callback(info); | 7795 callback(info); |
7789 } | 7796 } |
7790 | 7797 |
7791 | 7798 |
7792 } } // namespace v8::internal | 7799 } } // namespace v8::internal |
OLD | NEW |