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 8163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8174 | 8174 |
8175 | 8175 |
8176 Isolate* Isolate::GetCurrent() { | 8176 Isolate* Isolate::GetCurrent() { |
8177 i::Isolate* isolate = i::Isolate::Current(); | 8177 i::Isolate* isolate = i::Isolate::Current(); |
8178 return reinterpret_cast<Isolate*>(isolate); | 8178 return reinterpret_cast<Isolate*>(isolate); |
8179 } | 8179 } |
8180 | 8180 |
8181 | 8181 |
8182 Isolate* Isolate::New(const Isolate::CreateParams& params) { | 8182 Isolate* Isolate::New(const Isolate::CreateParams& params) { |
8183 i::Isolate* isolate = new i::Isolate(false); | 8183 i::Isolate* isolate = new i::Isolate(false); |
| 8184 return IsolateNewImpl(isolate, params); |
| 8185 } |
| 8186 |
| 8187 // This is separate so that tests can provide a different |isolate|. |
| 8188 Isolate* IsolateNewImpl(internal::Isolate* isolate, |
| 8189 const v8::Isolate::CreateParams& params) { |
8184 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); | 8190 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
8185 CHECK(params.array_buffer_allocator != NULL); | 8191 CHECK(params.array_buffer_allocator != NULL); |
8186 isolate->set_array_buffer_allocator(params.array_buffer_allocator); | 8192 isolate->set_array_buffer_allocator(params.array_buffer_allocator); |
8187 if (params.snapshot_blob != NULL) { | 8193 if (params.snapshot_blob != NULL) { |
8188 isolate->set_snapshot_blob(params.snapshot_blob); | 8194 isolate->set_snapshot_blob(params.snapshot_blob); |
8189 } else { | 8195 } else { |
8190 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); | 8196 isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); |
8191 } | 8197 } |
8192 if (params.entry_hook) { | 8198 if (params.entry_hook) { |
8193 #ifdef V8_USE_SNAPSHOT | 8199 #ifdef V8_USE_SNAPSHOT |
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10309 Address callback_address = | 10315 Address callback_address = |
10310 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10316 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10311 VMState<EXTERNAL> state(isolate); | 10317 VMState<EXTERNAL> state(isolate); |
10312 ExternalCallbackScope call_scope(isolate, callback_address); | 10318 ExternalCallbackScope call_scope(isolate, callback_address); |
10313 callback(info); | 10319 callback(info); |
10314 } | 10320 } |
10315 | 10321 |
10316 | 10322 |
10317 } // namespace internal | 10323 } // namespace internal |
10318 } // namespace v8 | 10324 } // namespace v8 |
OLD | NEW |