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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { | 299 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { |
300 i::V8::SetSnapshotBlob(snapshot_blob); | 300 i::V8::SetSnapshotBlob(snapshot_blob); |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 bool RunExtraCode(Isolate* isolate, const char* utf8_source) { | 304 bool RunExtraCode(Isolate* isolate, const char* utf8_source) { |
305 // Run custom script if provided. | 305 // Run custom script if provided. |
306 base::ElapsedTimer timer; | 306 base::ElapsedTimer timer; |
307 timer.Start(); | 307 timer.Start(); |
308 TryCatch try_catch; | 308 TryCatch try_catch(isolate); |
309 Local<String> source_string = String::NewFromUtf8(isolate, utf8_source); | 309 Local<String> source_string = String::NewFromUtf8(isolate, utf8_source); |
310 if (try_catch.HasCaught()) return false; | 310 if (try_catch.HasCaught()) return false; |
311 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); | 311 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); |
312 ScriptCompiler::Source source(source_string, origin); | 312 ScriptCompiler::Source source(source_string, origin); |
313 Local<Script> script = ScriptCompiler::Compile(isolate, &source); | 313 Local<Script> script = ScriptCompiler::Compile(isolate, &source); |
314 if (try_catch.HasCaught()) return false; | 314 if (try_catch.HasCaught()) return false; |
315 script->Run(); | 315 script->Run(); |
316 if (i::FLAG_profile_deserialization) { | 316 if (i::FLAG_profile_deserialization) { |
317 i::PrintF("Executing custom snapshot script took %0.3f ms\n", | 317 i::PrintF("Executing custom snapshot script took %0.3f ms\n", |
318 timer.Elapsed().InMillisecondsF()); | 318 timer.Elapsed().InMillisecondsF()); |
(...skipping 7147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7466 i::DisallowHeapAllocation no_allocation; | 7466 i::DisallowHeapAllocation no_allocation; |
7467 VisitorAdapter visitor_adapter(visitor); | 7467 VisitorAdapter visitor_adapter(visitor); |
7468 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( | 7468 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( |
7469 &visitor_adapter); | 7469 &visitor_adapter); |
7470 } | 7470 } |
7471 | 7471 |
7472 | 7472 |
7473 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 7473 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
7474 : str_(NULL), length_(0) { | 7474 : str_(NULL), length_(0) { |
7475 i::Isolate* isolate = i::Isolate::Current(); | 7475 i::Isolate* isolate = i::Isolate::Current(); |
| 7476 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
7476 if (obj.IsEmpty()) return; | 7477 if (obj.IsEmpty()) return; |
7477 ENTER_V8(isolate); | 7478 ENTER_V8(isolate); |
7478 i::HandleScope scope(isolate); | 7479 i::HandleScope scope(isolate); |
7479 TryCatch try_catch; | 7480 TryCatch try_catch(v8_isolate); |
7480 Handle<String> str = obj->ToString(reinterpret_cast<v8::Isolate*>(isolate)); | 7481 Handle<String> str = obj->ToString(v8_isolate); |
7481 if (str.IsEmpty()) return; | 7482 if (str.IsEmpty()) return; |
7482 i::Handle<i::String> i_str = Utils::OpenHandle(*str); | 7483 i::Handle<i::String> i_str = Utils::OpenHandle(*str); |
7483 length_ = v8::Utf8Length(*i_str, isolate); | 7484 length_ = v8::Utf8Length(*i_str, isolate); |
7484 str_ = i::NewArray<char>(length_ + 1); | 7485 str_ = i::NewArray<char>(length_ + 1); |
7485 str->WriteUtf8(str_); | 7486 str->WriteUtf8(str_); |
7486 } | 7487 } |
7487 | 7488 |
7488 | 7489 |
7489 String::Utf8Value::~Utf8Value() { | 7490 String::Utf8Value::~Utf8Value() { |
7490 i::DeleteArray(str_); | 7491 i::DeleteArray(str_); |
7491 } | 7492 } |
7492 | 7493 |
7493 | 7494 |
7494 String::Value::Value(v8::Handle<v8::Value> obj) | 7495 String::Value::Value(v8::Handle<v8::Value> obj) |
7495 : str_(NULL), length_(0) { | 7496 : str_(NULL), length_(0) { |
7496 i::Isolate* isolate = i::Isolate::Current(); | 7497 i::Isolate* isolate = i::Isolate::Current(); |
| 7498 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
7497 if (obj.IsEmpty()) return; | 7499 if (obj.IsEmpty()) return; |
7498 ENTER_V8(isolate); | 7500 ENTER_V8(isolate); |
7499 i::HandleScope scope(isolate); | 7501 i::HandleScope scope(isolate); |
7500 TryCatch try_catch; | 7502 TryCatch try_catch(v8_isolate); |
7501 Handle<String> str = obj->ToString(reinterpret_cast<v8::Isolate*>(isolate)); | 7503 Handle<String> str = obj->ToString(v8_isolate); |
7502 if (str.IsEmpty()) return; | 7504 if (str.IsEmpty()) return; |
7503 length_ = str->Length(); | 7505 length_ = str->Length(); |
7504 str_ = i::NewArray<uint16_t>(length_ + 1); | 7506 str_ = i::NewArray<uint16_t>(length_ + 1); |
7505 str->Write(str_); | 7507 str->Write(str_); |
7506 } | 7508 } |
7507 | 7509 |
7508 | 7510 |
7509 String::Value::~Value() { | 7511 String::Value::~Value() { |
7510 i::DeleteArray(str_); | 7512 i::DeleteArray(str_); |
7511 } | 7513 } |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8325 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8327 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8326 Address callback_address = | 8328 Address callback_address = |
8327 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8329 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8328 VMState<EXTERNAL> state(isolate); | 8330 VMState<EXTERNAL> state(isolate); |
8329 ExternalCallbackScope call_scope(isolate, callback_address); | 8331 ExternalCallbackScope call_scope(isolate, callback_address); |
8330 callback(info); | 8332 callback(info); |
8331 } | 8333 } |
8332 | 8334 |
8333 | 8335 |
8334 } } // namespace v8::internal | 8336 } } // namespace v8::internal |
OLD | NEW |