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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ASSERT(!(isolate)->external_caught_exception()); \ | 88 ASSERT(!(isolate)->external_caught_exception()); \ |
89 bool has_pending_exception = false | 89 bool has_pending_exception = false |
90 | 90 |
91 | 91 |
92 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \ | 92 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \ |
93 do { \ | 93 do { \ |
94 i::HandleScopeImplementer* handle_scope_implementer = \ | 94 i::HandleScopeImplementer* handle_scope_implementer = \ |
95 (isolate)->handle_scope_implementer(); \ | 95 (isolate)->handle_scope_implementer(); \ |
96 handle_scope_implementer->DecrementCallDepth(); \ | 96 handle_scope_implementer->DecrementCallDepth(); \ |
97 if (has_pending_exception) { \ | 97 if (has_pending_exception) { \ |
98 if (handle_scope_implementer->CallDepthIsZero() && \ | |
99 (isolate)->is_out_of_memory()) { \ | |
100 if (!(isolate)->ignore_out_of_memory()) \ | |
101 i::V8::FatalProcessOutOfMemory(NULL); \ | |
102 } \ | |
103 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ | 98 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ |
104 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ | 99 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ |
105 do_callback \ | 100 do_callback \ |
106 return value; \ | 101 return value; \ |
107 } \ | 102 } \ |
108 do_callback \ | 103 do_callback \ |
109 } while (false) | 104 } while (false) |
110 | 105 |
111 | 106 |
112 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \ | 107 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \ |
(...skipping 5120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5233 | 5228 |
5234 Handle<Value> v8::Context::GetSecurityToken() { | 5229 Handle<Value> v8::Context::GetSecurityToken() { |
5235 i::Isolate* isolate = i::Isolate::Current(); | 5230 i::Isolate* isolate = i::Isolate::Current(); |
5236 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5231 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5237 i::Object* security_token = env->security_token(); | 5232 i::Object* security_token = env->security_token(); |
5238 i::Handle<i::Object> token_handle(security_token, isolate); | 5233 i::Handle<i::Object> token_handle(security_token, isolate); |
5239 return Utils::ToLocal(token_handle); | 5234 return Utils::ToLocal(token_handle); |
5240 } | 5235 } |
5241 | 5236 |
5242 | 5237 |
5243 bool Context::HasOutOfMemoryException() { | |
5244 i::Handle<i::Context> env = Utils::OpenHandle(this); | |
5245 return env->has_out_of_memory(); | |
5246 } | |
5247 | |
5248 | |
5249 v8::Isolate* Context::GetIsolate() { | 5238 v8::Isolate* Context::GetIsolate() { |
5250 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5239 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5251 return reinterpret_cast<Isolate*>(env->GetIsolate()); | 5240 return reinterpret_cast<Isolate*>(env->GetIsolate()); |
5252 } | 5241 } |
5253 | 5242 |
5254 | 5243 |
5255 v8::Local<v8::Object> Context::Global() { | 5244 v8::Local<v8::Object> Context::Global() { |
5256 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5245 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5257 i::Isolate* isolate = context->GetIsolate(); | 5246 i::Isolate* isolate = context->GetIsolate(); |
5258 i::Handle<i::Object> global(context->global_proxy(), isolate); | 5247 i::Handle<i::Object> global(context->global_proxy(), isolate); |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6197 bool fits_into_int32_t = (value & (1 << 31)) == 0; | 6186 bool fits_into_int32_t = (value & (1 << 31)) == 0; |
6198 if (fits_into_int32_t) { | 6187 if (fits_into_int32_t) { |
6199 return Integer::New(isolate, static_cast<int32_t>(value)); | 6188 return Integer::New(isolate, static_cast<int32_t>(value)); |
6200 } | 6189 } |
6201 ENTER_V8(internal_isolate); | 6190 ENTER_V8(internal_isolate); |
6202 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6191 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
6203 return Utils::IntegerToLocal(result); | 6192 return Utils::IntegerToLocal(result); |
6204 } | 6193 } |
6205 | 6194 |
6206 | 6195 |
6207 void V8::IgnoreOutOfMemoryException() { | |
6208 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); | |
6209 } | |
6210 | |
6211 | |
6212 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 6196 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
6213 i::Isolate* isolate = i::Isolate::Current(); | 6197 i::Isolate* isolate = i::Isolate::Current(); |
6214 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); | 6198 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); |
6215 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); | 6199 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); |
6216 ENTER_V8(isolate); | 6200 ENTER_V8(isolate); |
6217 i::HandleScope scope(isolate); | 6201 i::HandleScope scope(isolate); |
6218 NeanderArray listeners(isolate->factory()->message_listeners()); | 6202 NeanderArray listeners(isolate->factory()->message_listeners()); |
6219 NeanderObject obj(isolate, 2); | 6203 NeanderObject obj(isolate, 2); |
6220 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); | 6204 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); |
6221 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() | 6205 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() |
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7597 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7581 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7598 Address callback_address = | 7582 Address callback_address = |
7599 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7583 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7600 VMState<EXTERNAL> state(isolate); | 7584 VMState<EXTERNAL> state(isolate); |
7601 ExternalCallbackScope call_scope(isolate, callback_address); | 7585 ExternalCallbackScope call_scope(isolate, callback_address); |
7602 callback(info); | 7586 callback(info); |
7603 } | 7587 } |
7604 | 7588 |
7605 | 7589 |
7606 } } // namespace v8::internal | 7590 } } // namespace v8::internal |
OLD | NEW |