Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: src/api.cc

Issue 516913003: Do not expose termination exceptions to the Exception API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comment Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/accessors.cc ('k') | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6802 matching lines...) Expand 10 before | Expand all | Expand 10 after
6813 str_ = i::NewArray<uint16_t>(length_ + 1); 6813 str_ = i::NewArray<uint16_t>(length_ + 1);
6814 str->Write(str_); 6814 str->Write(str_);
6815 } 6815 }
6816 6816
6817 6817
6818 String::Value::~Value() { 6818 String::Value::~Value() {
6819 i::DeleteArray(str_); 6819 i::DeleteArray(str_);
6820 } 6820 }
6821 6821
6822 6822
6823 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { 6823 #define DEFINE_ERROR(NAME) \
6824 i::Isolate* isolate = i::Isolate::Current(); 6824 Local<Value> Exception::NAME(v8::Handle<v8::String> raw_message) { \
6825 LOG_API(isolate, "RangeError"); 6825 i::Isolate* isolate = i::Isolate::Current(); \
6826 ON_BAILOUT(isolate, "v8::Exception::RangeError()", return Local<Value>()); 6826 LOG_API(isolate, #NAME); \
6827 ENTER_V8(isolate); 6827 ON_BAILOUT(isolate, "v8::Exception::" #NAME "()", return Local<Value>()); \
6828 i::Object* error; 6828 ENTER_V8(isolate); \
6829 { 6829 i::Object* error; \
6830 i::HandleScope scope(isolate); 6830 { \
6831 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); 6831 i::HandleScope scope(isolate); \
6832 i::Handle<i::Object> result = isolate->factory()->NewRangeError(message); 6832 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \
6833 error = *result; 6833 i::Handle<i::Object> result; \
6834 EXCEPTION_PREAMBLE(isolate); \
6835 i::MaybeHandle<i::Object> maybe_result = \
6836 isolate->factory()->New##NAME(message); \
6837 has_pending_exception = !maybe_result.ToHandle(&result); \
6838 /* TODO(yangguo): crbug/403509. Return empty handle instead. */ \
6839 EXCEPTION_BAILOUT_CHECK( \
6840 isolate, v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate))); \
6841 error = *result; \
6842 } \
6843 i::Handle<i::Object> result(error, isolate); \
6844 return Utils::ToLocal(result); \
6834 } 6845 }
6835 i::Handle<i::Object> result(error, isolate);
6836 return Utils::ToLocal(result);
6837 }
6838 6846
6847 DEFINE_ERROR(RangeError)
6848 DEFINE_ERROR(ReferenceError)
6849 DEFINE_ERROR(SyntaxError)
6850 DEFINE_ERROR(TypeError)
6851 DEFINE_ERROR(Error)
6839 6852
6840 Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) { 6853 #undef DEFINE_ERROR
6841 i::Isolate* isolate = i::Isolate::Current();
6842 LOG_API(isolate, "ReferenceError");
6843 ON_BAILOUT(isolate, "v8::Exception::ReferenceError()", return Local<Value>());
6844 ENTER_V8(isolate);
6845 i::Object* error;
6846 {
6847 i::HandleScope scope(isolate);
6848 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6849 i::Handle<i::Object> result =
6850 isolate->factory()->NewReferenceError(message);
6851 error = *result;
6852 }
6853 i::Handle<i::Object> result(error, isolate);
6854 return Utils::ToLocal(result);
6855 }
6856
6857
6858 Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) {
6859 i::Isolate* isolate = i::Isolate::Current();
6860 LOG_API(isolate, "SyntaxError");
6861 ON_BAILOUT(isolate, "v8::Exception::SyntaxError()", return Local<Value>());
6862 ENTER_V8(isolate);
6863 i::Object* error;
6864 {
6865 i::HandleScope scope(isolate);
6866 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6867 i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message);
6868 error = *result;
6869 }
6870 i::Handle<i::Object> result(error, isolate);
6871 return Utils::ToLocal(result);
6872 }
6873
6874
6875 Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) {
6876 i::Isolate* isolate = i::Isolate::Current();
6877 LOG_API(isolate, "TypeError");
6878 ON_BAILOUT(isolate, "v8::Exception::TypeError()", return Local<Value>());
6879 ENTER_V8(isolate);
6880 i::Object* error;
6881 {
6882 i::HandleScope scope(isolate);
6883 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6884 i::Handle<i::Object> result = isolate->factory()->NewTypeError(message);
6885 error = *result;
6886 }
6887 i::Handle<i::Object> result(error, isolate);
6888 return Utils::ToLocal(result);
6889 }
6890
6891
6892 Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) {
6893 i::Isolate* isolate = i::Isolate::Current();
6894 LOG_API(isolate, "Error");
6895 ON_BAILOUT(isolate, "v8::Exception::Error()", return Local<Value>());
6896 ENTER_V8(isolate);
6897 i::Object* error;
6898 {
6899 i::HandleScope scope(isolate);
6900 i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
6901 i::Handle<i::Object> result = isolate->factory()->NewError(message);
6902 error = *result;
6903 }
6904 i::Handle<i::Object> result(error, isolate);
6905 return Utils::ToLocal(result);
6906 }
6907 6854
6908 6855
6909 // --- D e b u g S u p p o r t --- 6856 // --- D e b u g S u p p o r t ---
6910 6857
6911 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { 6858 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
6912 i::Isolate* isolate = i::Isolate::Current(); 6859 i::Isolate* isolate = i::Isolate::Current();
6913 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()"); 6860 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()");
6914 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); 6861 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
6915 ENTER_V8(isolate); 6862 ENTER_V8(isolate);
6916 i::HandleScope scope(isolate); 6863 i::HandleScope scope(isolate);
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
7678 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7625 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7679 Address callback_address = 7626 Address callback_address =
7680 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7627 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7681 VMState<EXTERNAL> state(isolate); 7628 VMState<EXTERNAL> state(isolate);
7682 ExternalCallbackScope call_scope(isolate, callback_address); 7629 ExternalCallbackScope call_scope(isolate, callback_address);
7683 callback(info); 7630 callback(info);
7684 } 7631 }
7685 7632
7686 7633
7687 } } // namespace v8::internal 7634 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698