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 6368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6379 isolate->OptionalRescheduleException(true); | 6379 isolate->OptionalRescheduleException(true); |
6380 } | 6380 } |
6381 return MaybeLocal<Object>(); | 6381 return MaybeLocal<Object>(); |
6382 } | 6382 } |
6383 return Utils::ToLocal(scope.CloseAndEscape(object)); | 6383 return Utils::ToLocal(scope.CloseAndEscape(object)); |
6384 } | 6384 } |
6385 | 6385 |
6386 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { | 6386 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { |
6387 auto self = Utils::OpenHandle(this); | 6387 auto self = Utils::OpenHandle(this); |
6388 auto obj = Utils::OpenHandle(*value); | 6388 auto obj = Utils::OpenHandle(*value); |
6389 return obj->IsJSObject() && self->IsTemplateFor(i::JSObject::cast(*obj)); | 6389 if (obj->IsJSObject() && self->IsTemplateFor(i::JSObject::cast(*obj))) { |
| 6390 return true; |
| 6391 } |
| 6392 if (obj->IsJSGlobalProxy()) { |
| 6393 // If it's a global proxy object, then test with the global object. |
| 6394 i::PrototypeIterator iter(i::JSObject::cast(*obj)->map()); |
| 6395 if (iter.IsAtEnd()) return false; |
| 6396 return self->IsTemplateFor(iter.GetCurrent<i::JSGlobalObject>()); |
| 6397 } |
| 6398 return false; |
6390 } | 6399 } |
6391 | 6400 |
6392 | 6401 |
6393 Local<External> v8::External::New(Isolate* isolate, void* value) { | 6402 Local<External> v8::External::New(Isolate* isolate, void* value) { |
6394 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 6403 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
6395 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6404 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6396 LOG_API(i_isolate, External, New); | 6405 LOG_API(i_isolate, External, New); |
6397 ENTER_V8(i_isolate); | 6406 ENTER_V8(i_isolate); |
6398 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); | 6407 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); |
6399 return Utils::ExternalToLocal(external); | 6408 return Utils::ExternalToLocal(external); |
(...skipping 3384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9784 Address callback_address = | 9793 Address callback_address = |
9785 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9794 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9786 VMState<EXTERNAL> state(isolate); | 9795 VMState<EXTERNAL> state(isolate); |
9787 ExternalCallbackScope call_scope(isolate, callback_address); | 9796 ExternalCallbackScope call_scope(isolate, callback_address); |
9788 callback(info); | 9797 callback(info); |
9789 } | 9798 } |
9790 | 9799 |
9791 | 9800 |
9792 } // namespace internal | 9801 } // namespace internal |
9793 } // namespace v8 | 9802 } // namespace v8 |
OLD | NEW |