| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 | 83 |
| 84 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \ | 84 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \ |
| 85 do { \ | 85 do { \ |
| 86 i::HandleScopeImplementer* handle_scope_implementer = \ | 86 i::HandleScopeImplementer* handle_scope_implementer = \ |
| 87 (isolate)->handle_scope_implementer(); \ | 87 (isolate)->handle_scope_implementer(); \ |
| 88 handle_scope_implementer->DecrementCallDepth(); \ | 88 handle_scope_implementer->DecrementCallDepth(); \ |
| 89 if (has_pending_exception) { \ | 89 if (has_pending_exception) { \ |
| 90 if (handle_scope_implementer->CallDepthIsZero() && \ | 90 if (handle_scope_implementer->CallDepthIsZero() && \ |
| 91 (isolate)->is_out_of_memory()) { \ | 91 (isolate)->is_out_of_memory()) { \ |
| 92 if (!handle_scope_implementer->ignore_out_of_memory()) \ | 92 if (!(isolate)->ignore_out_of_memory()) \ |
| 93 i::V8::FatalProcessOutOfMemory(NULL); \ | 93 i::V8::FatalProcessOutOfMemory(NULL); \ |
| 94 } \ | 94 } \ |
| 95 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ | 95 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ |
| 96 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ | 96 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ |
| 97 return value; \ | 97 return value; \ |
| 98 } \ | 98 } \ |
| 99 } while (false) | 99 } while (false) |
| 100 | 100 |
| 101 // TODO(isolates): Add a parameter to this macro for an isolate. | 101 // TODO(isolates): Add a parameter to this macro for an isolate. |
| 102 | 102 |
| (...skipping 3796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3899 } | 3899 } |
| 3900 | 3900 |
| 3901 static void* ExternalValueImpl(i::Handle<i::Object> obj) { | 3901 static void* ExternalValueImpl(i::Handle<i::Object> obj) { |
| 3902 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy()); | 3902 return reinterpret_cast<void*>(i::Proxy::cast(*obj)->proxy()); |
| 3903 } | 3903 } |
| 3904 | 3904 |
| 3905 | 3905 |
| 3906 Local<Value> v8::External::Wrap(void* data) { | 3906 Local<Value> v8::External::Wrap(void* data) { |
| 3907 i::Isolate* isolate = i::Isolate::Current(); | 3907 i::Isolate* isolate = i::Isolate::Current(); |
| 3908 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 3908 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
| 3909 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()"); |
| 3909 LOG_API(isolate, "External::Wrap"); | 3910 LOG_API(isolate, "External::Wrap"); |
| 3910 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()"); | |
| 3911 ENTER_V8(isolate); | 3911 ENTER_V8(isolate); |
| 3912 | 3912 |
| 3913 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data) | 3913 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data) |
| 3914 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data))) | 3914 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data))) |
| 3915 : v8::Local<v8::Value>(ExternalNewImpl(data)); | 3915 : v8::Local<v8::Value>(ExternalNewImpl(data)); |
| 3916 | 3916 |
| 3917 ASSERT_EQ(data, Unwrap(result)); | 3917 ASSERT_EQ(data, Unwrap(result)); |
| 3918 return result; | 3918 return result; |
| 3919 } | 3919 } |
| 3920 | 3920 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3944 result = NULL; | 3944 result = NULL; |
| 3945 } | 3945 } |
| 3946 ASSERT_EQ(result, QuickUnwrap(wrapper)); | 3946 ASSERT_EQ(result, QuickUnwrap(wrapper)); |
| 3947 return result; | 3947 return result; |
| 3948 } | 3948 } |
| 3949 | 3949 |
| 3950 | 3950 |
| 3951 Local<External> v8::External::New(void* data) { | 3951 Local<External> v8::External::New(void* data) { |
| 3952 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); | 3952 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); |
| 3953 i::Isolate* isolate = i::Isolate::Current(); | 3953 i::Isolate* isolate = i::Isolate::Current(); |
| 3954 EnsureInitializedForIsolate(isolate, "v8::External::New()"); |
| 3954 LOG_API(isolate, "External::New"); | 3955 LOG_API(isolate, "External::New"); |
| 3955 EnsureInitializedForIsolate(isolate, "v8::External::New()"); | |
| 3956 ENTER_V8(isolate); | 3956 ENTER_V8(isolate); |
| 3957 return ExternalNewImpl(data); | 3957 return ExternalNewImpl(data); |
| 3958 } | 3958 } |
| 3959 | 3959 |
| 3960 | 3960 |
| 3961 void* External::Value() const { | 3961 void* External::Value() const { |
| 3962 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0; | 3962 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0; |
| 3963 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3963 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 3964 return ExternalValueImpl(obj); | 3964 return ExternalValueImpl(obj); |
| 3965 } | 3965 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 return Integer::New(static_cast<int32_t>(value)); | 4364 return Integer::New(static_cast<int32_t>(value)); |
| 4365 } | 4365 } |
| 4366 i::Isolate* isolate = i::Isolate::Current(); | 4366 i::Isolate* isolate = i::Isolate::Current(); |
| 4367 ENTER_V8(isolate); | 4367 ENTER_V8(isolate); |
| 4368 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); | 4368 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); |
| 4369 return Utils::IntegerToLocal(result); | 4369 return Utils::IntegerToLocal(result); |
| 4370 } | 4370 } |
| 4371 | 4371 |
| 4372 | 4372 |
| 4373 void V8::IgnoreOutOfMemoryException() { | 4373 void V8::IgnoreOutOfMemoryException() { |
| 4374 EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory( | 4374 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); |
| 4375 true); | |
| 4376 } | 4375 } |
| 4377 | 4376 |
| 4378 | 4377 |
| 4379 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 4378 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
| 4380 i::Isolate* isolate = i::Isolate::Current(); | 4379 i::Isolate* isolate = i::Isolate::Current(); |
| 4381 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); | 4380 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); |
| 4382 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); | 4381 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); |
| 4383 ENTER_V8(isolate); | 4382 ENTER_V8(isolate); |
| 4384 i::HandleScope scope(isolate); | 4383 i::HandleScope scope(isolate); |
| 4385 NeanderArray listeners(isolate->factory()->message_listeners()); | 4384 NeanderArray listeners(isolate->factory()->message_listeners()); |
| (...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5673 | 5672 |
| 5674 | 5673 |
| 5675 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5674 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5676 HandleScopeImplementer* scope_implementer = | 5675 HandleScopeImplementer* scope_implementer = |
| 5677 reinterpret_cast<HandleScopeImplementer*>(storage); | 5676 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5678 scope_implementer->IterateThis(v); | 5677 scope_implementer->IterateThis(v); |
| 5679 return storage + ArchiveSpacePerThread(); | 5678 return storage + ArchiveSpacePerThread(); |
| 5680 } | 5679 } |
| 5681 | 5680 |
| 5682 } } // namespace v8::internal | 5681 } } // namespace v8::internal |
| OLD | NEW |