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 8164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8175 | 8175 |
8176 | 8176 |
8177 Isolate* Isolate::GetCurrent() { | 8177 Isolate* Isolate::GetCurrent() { |
8178 i::Isolate* isolate = i::Isolate::Current(); | 8178 i::Isolate* isolate = i::Isolate::Current(); |
8179 return reinterpret_cast<Isolate*>(isolate); | 8179 return reinterpret_cast<Isolate*>(isolate); |
8180 } | 8180 } |
8181 | 8181 |
8182 | 8182 |
8183 Isolate* Isolate::New(const Isolate::CreateParams& params) { | 8183 Isolate* Isolate::New(const Isolate::CreateParams& params) { |
8184 i::Isolate* isolate = new i::Isolate(false); | 8184 i::Isolate* isolate = new i::Isolate(false); |
8185 return IsolateNewImpl(isolate, params); | |
8186 } | |
8187 | |
8188 // This is separate so that tests can provide a different |isolate|. | |
8189 Isolate* IsolateNewImpl(internal::Isolate* isolate, | |
8190 const v8::Isolate::CreateParams& params) { | |
8191 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); | 8185 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
8192 CHECK(params.array_buffer_allocator != NULL); | 8186 CHECK(params.array_buffer_allocator != NULL); |
8193 isolate->set_array_buffer_allocator(params.array_buffer_allocator); | 8187 isolate->set_array_buffer_allocator(params.array_buffer_allocator); |
8194 if (params.snapshot_blob != NULL) { | 8188 if (params.snapshot_blob != NULL) { |
8195 isolate->set_snapshot_blob(params.snapshot_blob); | 8189 isolate->set_snapshot_blob(params.snapshot_blob); |
8196 } else { | 8190 } else { |
8197 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); | 8191 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); |
8198 } | 8192 } |
8199 if (params.entry_hook) { | 8193 if (params.entry_hook) { |
8200 #ifdef V8_USE_SNAPSHOT | 8194 #ifdef V8_USE_SNAPSHOT |
(...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10356 Address callback_address = | 10350 Address callback_address = |
10357 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10351 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10358 VMState<EXTERNAL> state(isolate); | 10352 VMState<EXTERNAL> state(isolate); |
10359 ExternalCallbackScope call_scope(isolate, callback_address); | 10353 ExternalCallbackScope call_scope(isolate, callback_address); |
10360 callback(info); | 10354 callback(info); |
10361 } | 10355 } |
10362 | 10356 |
10363 | 10357 |
10364 } // namespace internal | 10358 } // namespace internal |
10365 } // namespace v8 | 10359 } // namespace v8 |
OLD | NEW |