| 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 6072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6083 | 6083 |
| 6084 | 6084 |
| 6085 Local<Object> Array::CloneElementAt(uint32_t index) { | 6085 Local<Object> Array::CloneElementAt(uint32_t index) { |
| 6086 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6086 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 6087 RETURN_TO_LOCAL_UNCHECKED(CloneElementAt(context, index), Object); | 6087 RETURN_TO_LOCAL_UNCHECKED(CloneElementAt(context, index), Object); |
| 6088 } | 6088 } |
| 6089 | 6089 |
| 6090 | 6090 |
| 6091 bool Value::IsPromise() const { | 6091 bool Value::IsPromise() const { |
| 6092 auto self = Utils::OpenHandle(this); | 6092 auto self = Utils::OpenHandle(this); |
| 6093 return i::Object::IsPromise(self); | 6093 if (!self->IsJSObject()) return false; |
| 6094 auto js_object = i::Handle<i::JSObject>::cast(self); |
| 6095 // Promises can't have access checks. |
| 6096 if (js_object->map()->is_access_check_needed()) return false; |
| 6097 auto isolate = js_object->GetIsolate(); |
| 6098 // TODO(dcarney): this should just be read from the symbol registry so as not |
| 6099 // to be context dependent. |
| 6100 auto key = isolate->promise_status(); |
| 6101 // Shouldn't be possible to throw here. |
| 6102 return i::JSObject::HasRealNamedProperty(js_object, key).FromJust(); |
| 6094 } | 6103 } |
| 6095 | 6104 |
| 6096 | 6105 |
| 6097 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6106 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
| 6098 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6107 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); |
| 6099 i::Handle<i::Object> result; | 6108 i::Handle<i::Object> result; |
| 6100 has_pending_exception = !i::Execution::Call( | 6109 has_pending_exception = !i::Execution::Call( |
| 6101 isolate, | 6110 isolate, |
| 6102 isolate->promise_create(), | 6111 isolate->promise_create(), |
| 6103 isolate->factory()->undefined_value(), | 6112 isolate->factory()->undefined_value(), |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7378 return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext()); | 7387 return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext()); |
| 7379 } | 7388 } |
| 7380 | 7389 |
| 7381 | 7390 |
| 7382 void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) { | 7391 void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) { |
| 7383 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7392 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7384 internal_isolate->debug()->set_live_edit_enabled(enable); | 7393 internal_isolate->debug()->set_live_edit_enabled(enable); |
| 7385 } | 7394 } |
| 7386 | 7395 |
| 7387 | 7396 |
| 7388 MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate, | |
| 7389 Local<Value> value) { | |
| 7390 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | |
| 7391 ENTER_V8(isolate); | |
| 7392 i::Handle<i::Object> val = Utils::OpenHandle(*value); | |
| 7393 i::Handle<i::JSArray> result; | |
| 7394 if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result)) | |
| 7395 return MaybeLocal<Array>(); | |
| 7396 return Utils::ToLocal(result); | |
| 7397 } | |
| 7398 | |
| 7399 | |
| 7400 Handle<String> CpuProfileNode::GetFunctionName() const { | 7397 Handle<String> CpuProfileNode::GetFunctionName() const { |
| 7401 i::Isolate* isolate = i::Isolate::Current(); | 7398 i::Isolate* isolate = i::Isolate::Current(); |
| 7402 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 7399 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 7403 const i::CodeEntry* entry = node->entry(); | 7400 const i::CodeEntry* entry = node->entry(); |
| 7404 i::Handle<i::String> name = | 7401 i::Handle<i::String> name = |
| 7405 isolate->factory()->InternalizeUtf8String(entry->name()); | 7402 isolate->factory()->InternalizeUtf8String(entry->name()); |
| 7406 if (!entry->has_name_prefix()) { | 7403 if (!entry->has_name_prefix()) { |
| 7407 return ToApiHandle<String>(name); | 7404 return ToApiHandle<String>(name); |
| 7408 } else { | 7405 } else { |
| 7409 // We do not expect this to fail. Change this if it does. | 7406 // We do not expect this to fail. Change this if it does. |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8035 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8032 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8036 Address callback_address = | 8033 Address callback_address = |
| 8037 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8034 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8038 VMState<EXTERNAL> state(isolate); | 8035 VMState<EXTERNAL> state(isolate); |
| 8039 ExternalCallbackScope call_scope(isolate, callback_address); | 8036 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8040 callback(info); | 8037 callback(info); |
| 8041 } | 8038 } |
| 8042 | 8039 |
| 8043 | 8040 |
| 8044 } } // namespace v8::internal | 8041 } } // namespace v8::internal |
| OLD | NEW |