| 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 if (!self->IsJSObject()) return false; | 6093 return i::Object::IsPromise(self); |
| 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(); | |
| 6103 } | 6094 } |
| 6104 | 6095 |
| 6105 | 6096 |
| 6106 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6097 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
| 6107 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6098 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); |
| 6108 i::Handle<i::Object> result; | 6099 i::Handle<i::Object> result; |
| 6109 has_pending_exception = !i::Execution::Call( | 6100 has_pending_exception = !i::Execution::Call( |
| 6110 isolate, | 6101 isolate, |
| 6111 isolate->promise_create(), | 6102 isolate->promise_create(), |
| 6112 isolate->factory()->undefined_value(), | 6103 isolate->factory()->undefined_value(), |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7387 return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext()); | 7378 return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext()); |
| 7388 } | 7379 } |
| 7389 | 7380 |
| 7390 | 7381 |
| 7391 void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) { | 7382 void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) { |
| 7392 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7383 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7393 internal_isolate->debug()->set_live_edit_enabled(enable); | 7384 internal_isolate->debug()->set_live_edit_enabled(enable); |
| 7394 } | 7385 } |
| 7395 | 7386 |
| 7396 | 7387 |
| 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 |
| 7397 Handle<String> CpuProfileNode::GetFunctionName() const { | 7400 Handle<String> CpuProfileNode::GetFunctionName() const { |
| 7398 i::Isolate* isolate = i::Isolate::Current(); | 7401 i::Isolate* isolate = i::Isolate::Current(); |
| 7399 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 7402 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 7400 const i::CodeEntry* entry = node->entry(); | 7403 const i::CodeEntry* entry = node->entry(); |
| 7401 i::Handle<i::String> name = | 7404 i::Handle<i::String> name = |
| 7402 isolate->factory()->InternalizeUtf8String(entry->name()); | 7405 isolate->factory()->InternalizeUtf8String(entry->name()); |
| 7403 if (!entry->has_name_prefix()) { | 7406 if (!entry->has_name_prefix()) { |
| 7404 return ToApiHandle<String>(name); | 7407 return ToApiHandle<String>(name); |
| 7405 } else { | 7408 } else { |
| 7406 // We do not expect this to fail. Change this if it does. | 7409 // 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... |
| 8032 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8035 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8033 Address callback_address = | 8036 Address callback_address = |
| 8034 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8037 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8035 VMState<EXTERNAL> state(isolate); | 8038 VMState<EXTERNAL> state(isolate); |
| 8036 ExternalCallbackScope call_scope(isolate, callback_address); | 8039 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8037 callback(info); | 8040 callback(info); |
| 8038 } | 8041 } |
| 8039 | 8042 |
| 8040 | 8043 |
| 8041 } } // namespace v8::internal | 8044 } } // namespace v8::internal |
| OLD | NEW |