| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) { | 292 static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) { |
| 293 return obj.IsEmpty() ? ReportEmptyHandle(location) : false; | 293 return obj.IsEmpty() ? ReportEmptyHandle(location) : false; |
| 294 } | 294 } |
| 295 | 295 |
| 296 | 296 |
| 297 static inline bool EmptyCheck(const char* location, const v8::Data* obj) { | 297 static inline bool EmptyCheck(const char* location, const v8::Data* obj) { |
| 298 return (obj == 0) ? ReportEmptyHandle(location) : false; | 298 return (obj == 0) ? ReportEmptyHandle(location) : false; |
| 299 } | 299 } |
| 300 | 300 |
| 301 |
| 301 // --- S t a t i c s --- | 302 // --- S t a t i c s --- |
| 302 | 303 |
| 303 | 304 |
| 304 static bool InitializeHelper(i::Isolate* isolate) { | 305 static bool InitializeHelper(i::Isolate* isolate) { |
| 305 // If the isolate has a function entry hook, it needs to re-build all its | 306 // If the isolate has a function entry hook, it needs to re-build all its |
| 306 // code stubs with entry hooks embedded, so let's deserialize a snapshot. | 307 // code stubs with entry hooks embedded, so let's deserialize a snapshot. |
| 307 if (isolate == NULL || isolate->function_entry_hook() == NULL) { | 308 if (isolate == NULL || isolate->function_entry_hook() == NULL) { |
| 308 if (i::Snapshot::Initialize()) | 309 if (i::Snapshot::Initialize()) |
| 309 return true; | 310 return true; |
| 310 } | 311 } |
| 311 return i::V8::Initialize(NULL); | 312 return i::V8::Initialize(NULL); |
| 312 } | 313 } |
| 313 | 314 |
| 314 | 315 |
| 315 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, | 316 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, |
| 316 const char* location) { | 317 const char* location) { |
| 317 if (IsDeadCheck(isolate, location)) return false; | 318 if (IsDeadCheck(isolate, location)) return false; |
| 318 if (isolate != NULL) { | 319 if (isolate != NULL) { |
| 319 if (isolate->IsInitialized()) return true; | 320 if (isolate->IsInitialized()) return true; |
| 320 } | 321 } |
| 321 ASSERT(isolate == i::Isolate::Current()); | 322 ASSERT(isolate == i::Isolate::Current()); |
| 322 return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8"); | 323 return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8"); |
| 323 } | 324 } |
| 324 | 325 |
| 326 |
| 325 // Some initializing API functions are called early and may be | 327 // Some initializing API functions are called early and may be |
| 326 // called on a thread different from static initializer thread. | 328 // called on a thread different from static initializer thread. |
| 327 // If Isolate API is used, Isolate::Enter() will initialize TLS so | 329 // If Isolate API is used, Isolate::Enter() will initialize TLS so |
| 328 // Isolate::Current() works. If it's a legacy case, then the thread | 330 // Isolate::Current() works. If it's a legacy case, then the thread |
| 329 // may not have TLS initialized yet. However, in initializing APIs it | 331 // may not have TLS initialized yet. However, in initializing APIs it |
| 330 // may be too early to call EnsureInitialized() - some pre-init | 332 // may be too early to call EnsureInitialized() - some pre-init |
| 331 // parameters still have to be configured. | 333 // parameters still have to be configured. |
| 332 static inline i::Isolate* EnterIsolateIfNeeded() { | 334 static inline i::Isolate* EnterIsolateIfNeeded() { |
| 333 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 335 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 334 if (isolate != NULL) | 336 if (isolate != NULL) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 kSnapshot = 0, | 396 kSnapshot = 0, |
| 395 kSnapshotContext, | 397 kSnapshotContext, |
| 396 kLibraries, | 398 kLibraries, |
| 397 kExperimentalLibraries, | 399 kExperimentalLibraries, |
| 398 #if defined(ENABLE_I18N_SUPPORT) | 400 #if defined(ENABLE_I18N_SUPPORT) |
| 399 kI18NExtension, | 401 kI18NExtension, |
| 400 #endif | 402 #endif |
| 401 kCompressedStartupDataCount | 403 kCompressedStartupDataCount |
| 402 }; | 404 }; |
| 403 | 405 |
| 406 |
| 404 int V8::GetCompressedStartupDataCount() { | 407 int V8::GetCompressedStartupDataCount() { |
| 405 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 408 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 406 return kCompressedStartupDataCount; | 409 return kCompressedStartupDataCount; |
| 407 #else | 410 #else |
| 408 return 0; | 411 return 0; |
| 409 #endif | 412 #endif |
| 410 } | 413 } |
| 411 | 414 |
| 412 | 415 |
| 413 void V8::GetCompressedStartupData(StartupData* compressed_data) { | 416 void V8::GetCompressedStartupData(StartupData* compressed_data) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 666 |
| 664 void V8::ClearWeak(i::Object** obj) { | 667 void V8::ClearWeak(i::Object** obj) { |
| 665 i::GlobalHandles::ClearWeakness(obj); | 668 i::GlobalHandles::ClearWeakness(obj); |
| 666 } | 669 } |
| 667 | 670 |
| 668 | 671 |
| 669 void V8::DisposeGlobal(i::Object** obj) { | 672 void V8::DisposeGlobal(i::Object** obj) { |
| 670 i::GlobalHandles::Destroy(obj); | 673 i::GlobalHandles::Destroy(obj); |
| 671 } | 674 } |
| 672 | 675 |
| 676 |
| 673 // --- H a n d l e s --- | 677 // --- H a n d l e s --- |
| 674 | 678 |
| 675 | 679 |
| 676 HandleScope::HandleScope() { | 680 HandleScope::HandleScope() { |
| 677 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); | 681 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); |
| 678 } | 682 } |
| 679 | 683 |
| 680 | 684 |
| 681 HandleScope::HandleScope(Isolate* isolate) { | 685 HandleScope::HandleScope(Isolate* isolate) { |
| 682 Initialize(isolate); | 686 Initialize(isolate); |
| (...skipping 3732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4415 | 4419 |
| 4416 | 4420 |
| 4417 bool String::IsOneByte() const { | 4421 bool String::IsOneByte() const { |
| 4418 i::Handle<i::String> str = Utils::OpenHandle(this); | 4422 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 4419 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { | 4423 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { |
| 4420 return false; | 4424 return false; |
| 4421 } | 4425 } |
| 4422 return str->HasOnlyOneByteChars(); | 4426 return str->HasOnlyOneByteChars(); |
| 4423 } | 4427 } |
| 4424 | 4428 |
| 4429 |
| 4425 // Helpers for ContainsOnlyOneByteHelper | 4430 // Helpers for ContainsOnlyOneByteHelper |
| 4426 template<size_t size> struct OneByteMask; | 4431 template<size_t size> struct OneByteMask; |
| 4427 template<> struct OneByteMask<4> { | 4432 template<> struct OneByteMask<4> { |
| 4428 static const uint32_t value = 0xFF00FF00; | 4433 static const uint32_t value = 0xFF00FF00; |
| 4429 }; | 4434 }; |
| 4430 template<> struct OneByteMask<8> { | 4435 template<> struct OneByteMask<8> { |
| 4431 static const uint64_t value = V8_2PART_UINT64_C(0xFF00FF00, FF00FF00); | 4436 static const uint64_t value = V8_2PART_UINT64_C(0xFF00FF00, FF00FF00); |
| 4432 }; | 4437 }; |
| 4433 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value; | 4438 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value; |
| 4434 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; | 4439 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; |
| 4435 static inline bool Unaligned(const uint16_t* chars) { | 4440 static inline bool Unaligned(const uint16_t* chars) { |
| 4436 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; | 4441 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; |
| 4437 } | 4442 } |
| 4443 |
| 4444 |
| 4438 static inline const uint16_t* Align(const uint16_t* chars) { | 4445 static inline const uint16_t* Align(const uint16_t* chars) { |
| 4439 return reinterpret_cast<uint16_t*>( | 4446 return reinterpret_cast<uint16_t*>( |
| 4440 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); | 4447 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); |
| 4441 } | 4448 } |
| 4442 | 4449 |
| 4443 class ContainsOnlyOneByteHelper { | 4450 class ContainsOnlyOneByteHelper { |
| 4444 public: | 4451 public: |
| 4445 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} | 4452 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} |
| 4446 bool Check(i::String* string) { | 4453 bool Check(i::String* string) { |
| 4447 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); | 4454 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); |
| (...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6274 has_pending_exception = result.is_null(); | 6281 has_pending_exception = result.is_null(); |
| 6275 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | 6282 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); |
| 6276 return Utils::ToLocal(result); | 6283 return Utils::ToLocal(result); |
| 6277 } | 6284 } |
| 6278 | 6285 |
| 6279 | 6286 |
| 6280 bool v8::ArrayBuffer::IsExternal() const { | 6287 bool v8::ArrayBuffer::IsExternal() const { |
| 6281 return Utils::OpenHandle(this)->is_external(); | 6288 return Utils::OpenHandle(this)->is_external(); |
| 6282 } | 6289 } |
| 6283 | 6290 |
| 6291 |
| 6284 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 6292 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
| 6285 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6293 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
| 6286 ApiCheck(!obj->is_external(), | 6294 ApiCheck(!obj->is_external(), |
| 6287 "v8::ArrayBuffer::Externalize", | 6295 "v8::ArrayBuffer::Externalize", |
| 6288 "ArrayBuffer already externalized"); | 6296 "ArrayBuffer already externalized"); |
| 6289 obj->set_is_external(true); | 6297 obj->set_is_external(true); |
| 6290 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); | 6298 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); |
| 6291 Contents contents; | 6299 Contents contents; |
| 6292 contents.data_ = obj->backing_store(); | 6300 contents.data_ = obj->backing_store(); |
| 6293 contents.byte_length_ = byte_length; | 6301 contents.byte_length_ = byte_length; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6574 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6582 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6575 return Utils::IntegerToLocal(result); | 6583 return Utils::IntegerToLocal(result); |
| 6576 } | 6584 } |
| 6577 | 6585 |
| 6578 | 6586 |
| 6579 #ifdef DEBUG | 6587 #ifdef DEBUG |
| 6580 v8::AssertNoGCScope::AssertNoGCScope(v8::Isolate* isolate) { | 6588 v8::AssertNoGCScope::AssertNoGCScope(v8::Isolate* isolate) { |
| 6581 disallow_heap_allocation_ = new i::DisallowHeapAllocation(); | 6589 disallow_heap_allocation_ = new i::DisallowHeapAllocation(); |
| 6582 } | 6590 } |
| 6583 | 6591 |
| 6592 |
| 6584 v8::AssertNoGCScope::~AssertNoGCScope() { | 6593 v8::AssertNoGCScope::~AssertNoGCScope() { |
| 6585 delete static_cast<i::DisallowHeapAllocation*>(disallow_heap_allocation_); | 6594 delete static_cast<i::DisallowHeapAllocation*>(disallow_heap_allocation_); |
| 6586 } | 6595 } |
| 6587 #endif | 6596 #endif |
| 6588 | 6597 |
| 6589 | 6598 |
| 6590 void V8::IgnoreOutOfMemoryException() { | 6599 void V8::IgnoreOutOfMemoryException() { |
| 6591 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); | 6600 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); |
| 6592 } | 6601 } |
| 6593 | 6602 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6637 options); | 6646 options); |
| 6638 } | 6647 } |
| 6639 | 6648 |
| 6640 | 6649 |
| 6641 void V8::SetCounterFunction(CounterLookupCallback callback) { | 6650 void V8::SetCounterFunction(CounterLookupCallback callback) { |
| 6642 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6651 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 6643 if (IsDeadCheck(isolate, "v8::V8::SetCounterFunction()")) return; | 6652 if (IsDeadCheck(isolate, "v8::V8::SetCounterFunction()")) return; |
| 6644 isolate->stats_table()->SetCounterFunction(callback); | 6653 isolate->stats_table()->SetCounterFunction(callback); |
| 6645 } | 6654 } |
| 6646 | 6655 |
| 6656 |
| 6647 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { | 6657 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { |
| 6648 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6658 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 6649 if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return; | 6659 if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return; |
| 6650 isolate->stats_table()->SetCreateHistogramFunction(callback); | 6660 isolate->stats_table()->SetCreateHistogramFunction(callback); |
| 6651 isolate->InitializeLoggingAndCounters(); | 6661 isolate->InitializeLoggingAndCounters(); |
| 6652 isolate->counters()->ResetHistograms(); | 6662 isolate->counters()->ResetHistograms(); |
| 6653 } | 6663 } |
| 6654 | 6664 |
| 6665 |
| 6655 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { | 6666 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { |
| 6656 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6667 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 6657 if (IsDeadCheck(isolate, "v8::V8::SetAddHistogramSampleFunction()")) return; | 6668 if (IsDeadCheck(isolate, "v8::V8::SetAddHistogramSampleFunction()")) return; |
| 6658 isolate->stats_table()-> | 6669 isolate->stats_table()-> |
| 6659 SetAddHistogramSampleFunction(callback); | 6670 SetAddHistogramSampleFunction(callback); |
| 6660 } | 6671 } |
| 6661 | 6672 |
| 6662 void V8::SetFailedAccessCheckCallbackFunction( | 6673 void V8::SetFailedAccessCheckCallbackFunction( |
| 6663 FailedAccessCheckCallback callback) { | 6674 FailedAccessCheckCallback callback) { |
| 6664 i::Isolate* isolate = i::Isolate::Current(); | 6675 i::Isolate* isolate = i::Isolate::Current(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6992 length_ = str->Length(); | 7003 length_ = str->Length(); |
| 6993 str_ = i::NewArray<uint16_t>(length_ + 1); | 7004 str_ = i::NewArray<uint16_t>(length_ + 1); |
| 6994 str->Write(str_); | 7005 str->Write(str_); |
| 6995 } | 7006 } |
| 6996 | 7007 |
| 6997 | 7008 |
| 6998 String::Value::~Value() { | 7009 String::Value::~Value() { |
| 6999 i::DeleteArray(str_); | 7010 i::DeleteArray(str_); |
| 7000 } | 7011 } |
| 7001 | 7012 |
| 7013 |
| 7002 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { | 7014 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { |
| 7003 i::Isolate* isolate = i::Isolate::Current(); | 7015 i::Isolate* isolate = i::Isolate::Current(); |
| 7004 LOG_API(isolate, "RangeError"); | 7016 LOG_API(isolate, "RangeError"); |
| 7005 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>()); | 7017 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>()); |
| 7006 ENTER_V8(isolate); | 7018 ENTER_V8(isolate); |
| 7007 i::Object* error; | 7019 i::Object* error; |
| 7008 { | 7020 { |
| 7009 i::HandleScope scope(isolate); | 7021 i::HandleScope scope(isolate); |
| 7010 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 7022 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
| 7011 i::Handle<i::Object> result = isolate->factory()->NewRangeError(message); | 7023 i::Handle<i::Object> result = isolate->factory()->NewRangeError(message); |
| 7012 error = *result; | 7024 error = *result; |
| 7013 } | 7025 } |
| 7014 i::Handle<i::Object> result(error, isolate); | 7026 i::Handle<i::Object> result(error, isolate); |
| 7015 return Utils::ToLocal(result); | 7027 return Utils::ToLocal(result); |
| 7016 } | 7028 } |
| 7017 | 7029 |
| 7030 |
| 7018 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { | 7031 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { |
| 7019 i::Isolate* isolate = i::Isolate::Current(); | 7032 i::Isolate* isolate = i::Isolate::Current(); |
| 7020 LOG_API(isolate, "ReferenceError"); | 7033 LOG_API(isolate, "ReferenceError"); |
| 7021 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>()); | 7034 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>()); |
| 7022 ENTER_V8(isolate); | 7035 ENTER_V8(isolate); |
| 7023 i::Object* error; | 7036 i::Object* error; |
| 7024 { | 7037 { |
| 7025 i::HandleScope scope(isolate); | 7038 i::HandleScope scope(isolate); |
| 7026 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 7039 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
| 7027 i::Handle<i::Object> result = | 7040 i::Handle<i::Object> result = |
| 7028 isolate->factory()->NewReferenceError(message); | 7041 isolate->factory()->NewReferenceError(message); |
| 7029 error = *result; | 7042 error = *result; |
| 7030 } | 7043 } |
| 7031 i::Handle<i::Object> result(error, isolate); | 7044 i::Handle<i::Object> result(error, isolate); |
| 7032 return Utils::ToLocal(result); | 7045 return Utils::ToLocal(result); |
| 7033 } | 7046 } |
| 7034 | 7047 |
| 7048 |
| 7035 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) { | 7049 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) { |
| 7036 i::Isolate* isolate = i::Isolate::Current(); | 7050 i::Isolate* isolate = i::Isolate::Current(); |
| 7037 LOG_API(isolate, "SyntaxError"); | 7051 LOG_API(isolate, "SyntaxError"); |
| 7038 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>()); | 7052 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>()); |
| 7039 ENTER_V8(isolate); | 7053 ENTER_V8(isolate); |
| 7040 i::Object* error; | 7054 i::Object* error; |
| 7041 { | 7055 { |
| 7042 i::HandleScope scope(isolate); | 7056 i::HandleScope scope(isolate); |
| 7043 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 7057 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
| 7044 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message); | 7058 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message); |
| 7045 error = *result; | 7059 error = *result; |
| 7046 } | 7060 } |
| 7047 i::Handle<i::Object> result(error, isolate); | 7061 i::Handle<i::Object> result(error, isolate); |
| 7048 return Utils::ToLocal(result); | 7062 return Utils::ToLocal(result); |
| 7049 } | 7063 } |
| 7050 | 7064 |
| 7065 |
| 7051 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) { | 7066 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) { |
| 7052 i::Isolate* isolate = i::Isolate::Current(); | 7067 i::Isolate* isolate = i::Isolate::Current(); |
| 7053 LOG_API(isolate, "TypeError"); | 7068 LOG_API(isolate, "TypeError"); |
| 7054 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>()); | 7069 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>()); |
| 7055 ENTER_V8(isolate); | 7070 ENTER_V8(isolate); |
| 7056 i::Object* error; | 7071 i::Object* error; |
| 7057 { | 7072 { |
| 7058 i::HandleScope scope(isolate); | 7073 i::HandleScope scope(isolate); |
| 7059 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 7074 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
| 7060 i::Handle<i::Object> result = isolate->factory()->NewTypeError(message); | 7075 i::Handle<i::Object> result = isolate->factory()->NewTypeError(message); |
| 7061 error = *result; | 7076 error = *result; |
| 7062 } | 7077 } |
| 7063 i::Handle<i::Object> result(error, isolate); | 7078 i::Handle<i::Object> result(error, isolate); |
| 7064 return Utils::ToLocal(result); | 7079 return Utils::ToLocal(result); |
| 7065 } | 7080 } |
| 7066 | 7081 |
| 7082 |
| 7067 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) { | 7083 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) { |
| 7068 i::Isolate* isolate = i::Isolate::Current(); | 7084 i::Isolate* isolate = i::Isolate::Current(); |
| 7069 LOG_API(isolate, "Error"); | 7085 LOG_API(isolate, "Error"); |
| 7070 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>()); | 7086 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>()); |
| 7071 ENTER_V8(isolate); | 7087 ENTER_V8(isolate); |
| 7072 i::Object* error; | 7088 i::Object* error; |
| 7073 { | 7089 { |
| 7074 i::HandleScope scope(isolate); | 7090 i::HandleScope scope(isolate); |
| 7075 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); | 7091 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); |
| 7076 i::Handle<i::Object> result = isolate->factory()->NewError(message); | 7092 i::Handle<i::Object> result = isolate->factory()->NewError(message); |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7807 | 7823 |
| 7808 | 7824 |
| 7809 v8::Testing::StressType internal::Testing::stress_type_ = | 7825 v8::Testing::StressType internal::Testing::stress_type_ = |
| 7810 v8::Testing::kStressTypeOpt; | 7826 v8::Testing::kStressTypeOpt; |
| 7811 | 7827 |
| 7812 | 7828 |
| 7813 void Testing::SetStressRunType(Testing::StressType type) { | 7829 void Testing::SetStressRunType(Testing::StressType type) { |
| 7814 internal::Testing::set_stress_type(type); | 7830 internal::Testing::set_stress_type(type); |
| 7815 } | 7831 } |
| 7816 | 7832 |
| 7833 |
| 7817 int Testing::GetStressRuns() { | 7834 int Testing::GetStressRuns() { |
| 7818 if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs; | 7835 if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs; |
| 7819 #ifdef DEBUG | 7836 #ifdef DEBUG |
| 7820 // In debug mode the code runs much slower so stressing will only make two | 7837 // In debug mode the code runs much slower so stressing will only make two |
| 7821 // runs. | 7838 // runs. |
| 7822 return 2; | 7839 return 2; |
| 7823 #else | 7840 #else |
| 7824 return 5; | 7841 return 5; |
| 7825 #endif | 7842 #endif |
| 7826 } | 7843 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8063 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8080 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8064 Address callback_address = | 8081 Address callback_address = |
| 8065 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8082 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8066 VMState<EXTERNAL> state(isolate); | 8083 VMState<EXTERNAL> state(isolate); |
| 8067 ExternalCallbackScope call_scope(isolate, callback_address); | 8084 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8068 return callback(info); | 8085 return callback(info); |
| 8069 } | 8086 } |
| 8070 | 8087 |
| 8071 | 8088 |
| 8072 } } // namespace v8::internal | 8089 } } // namespace v8::internal |
| OLD | NEW |