| 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 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 DCHECK_EQ(result, QuickIsString()); | 2695 DCHECK_EQ(result, QuickIsString()); |
| 2696 return result; | 2696 return result; |
| 2697 } | 2697 } |
| 2698 | 2698 |
| 2699 | 2699 |
| 2700 bool Value::IsSymbol() const { | 2700 bool Value::IsSymbol() const { |
| 2701 return Utils::OpenHandle(this)->IsSymbol(); | 2701 return Utils::OpenHandle(this)->IsSymbol(); |
| 2702 } | 2702 } |
| 2703 | 2703 |
| 2704 | 2704 |
| 2705 bool Value::IsFloat32x4() const { |
| 2706 return Utils::OpenHandle(this)->IsFloat32x4(); |
| 2707 } |
| 2708 |
| 2709 |
| 2705 bool Value::IsArray() const { | 2710 bool Value::IsArray() const { |
| 2706 return Utils::OpenHandle(this)->IsJSArray(); | 2711 return Utils::OpenHandle(this)->IsJSArray(); |
| 2707 } | 2712 } |
| 2708 | 2713 |
| 2709 | 2714 |
| 2710 bool Value::IsArrayBuffer() const { | 2715 bool Value::IsArrayBuffer() const { |
| 2711 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2716 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2712 return obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(); | 2717 return obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(); |
| 2713 } | 2718 } |
| 2714 | 2719 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 if (!obj->IsHeapObject()) return false; \ | 2768 if (!obj->IsHeapObject()) return false; \ |
| 2764 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); \ | 2769 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); \ |
| 2765 return obj->HasSpecificClassOf(isolate->heap()->Class##_string()); \ | 2770 return obj->HasSpecificClassOf(isolate->heap()->Class##_string()); \ |
| 2766 } | 2771 } |
| 2767 | 2772 |
| 2768 VALUE_IS_SPECIFIC_TYPE(ArgumentsObject, Arguments) | 2773 VALUE_IS_SPECIFIC_TYPE(ArgumentsObject, Arguments) |
| 2769 VALUE_IS_SPECIFIC_TYPE(BooleanObject, Boolean) | 2774 VALUE_IS_SPECIFIC_TYPE(BooleanObject, Boolean) |
| 2770 VALUE_IS_SPECIFIC_TYPE(NumberObject, Number) | 2775 VALUE_IS_SPECIFIC_TYPE(NumberObject, Number) |
| 2771 VALUE_IS_SPECIFIC_TYPE(StringObject, String) | 2776 VALUE_IS_SPECIFIC_TYPE(StringObject, String) |
| 2772 VALUE_IS_SPECIFIC_TYPE(SymbolObject, Symbol) | 2777 VALUE_IS_SPECIFIC_TYPE(SymbolObject, Symbol) |
| 2778 VALUE_IS_SPECIFIC_TYPE(Float32x4Object, Float32x4) |
| 2773 VALUE_IS_SPECIFIC_TYPE(Date, Date) | 2779 VALUE_IS_SPECIFIC_TYPE(Date, Date) |
| 2774 VALUE_IS_SPECIFIC_TYPE(Map, Map) | 2780 VALUE_IS_SPECIFIC_TYPE(Map, Map) |
| 2775 VALUE_IS_SPECIFIC_TYPE(Set, Set) | 2781 VALUE_IS_SPECIFIC_TYPE(Set, Set) |
| 2776 VALUE_IS_SPECIFIC_TYPE(WeakMap, WeakMap) | 2782 VALUE_IS_SPECIFIC_TYPE(WeakMap, WeakMap) |
| 2777 VALUE_IS_SPECIFIC_TYPE(WeakSet, WeakSet) | 2783 VALUE_IS_SPECIFIC_TYPE(WeakSet, WeakSet) |
| 2778 | 2784 |
| 2779 #undef VALUE_IS_SPECIFIC_TYPE | 2785 #undef VALUE_IS_SPECIFIC_TYPE |
| 2780 | 2786 |
| 2781 | 2787 |
| 2782 bool Value::IsBoolean() const { | 2788 bool Value::IsBoolean() const { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3064 | 3070 |
| 3065 | 3071 |
| 3066 void v8::Symbol::CheckCast(v8::Value* that) { | 3072 void v8::Symbol::CheckCast(v8::Value* that) { |
| 3067 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3073 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3068 Utils::ApiCheck(obj->IsSymbol(), | 3074 Utils::ApiCheck(obj->IsSymbol(), |
| 3069 "v8::Symbol::Cast()", | 3075 "v8::Symbol::Cast()", |
| 3070 "Could not convert to symbol"); | 3076 "Could not convert to symbol"); |
| 3071 } | 3077 } |
| 3072 | 3078 |
| 3073 | 3079 |
| 3080 void v8::Float32x4::CheckCast(v8::Value* that) { |
| 3081 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3082 Utils::ApiCheck(obj->IsFloat32x4(), "v8::Float32x4::Cast()", |
| 3083 "Could not convert to float32x4"); |
| 3084 } |
| 3085 |
| 3086 |
| 3074 void v8::Number::CheckCast(v8::Value* that) { | 3087 void v8::Number::CheckCast(v8::Value* that) { |
| 3075 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3088 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3076 Utils::ApiCheck(obj->IsNumber(), | 3089 Utils::ApiCheck(obj->IsNumber(), |
| 3077 "v8::Number::Cast()", | 3090 "v8::Number::Cast()", |
| 3078 "Could not convert to number"); | 3091 "Could not convert to number"); |
| 3079 } | 3092 } |
| 3080 | 3093 |
| 3081 | 3094 |
| 3082 void v8::Integer::CheckCast(v8::Value* that) { | 3095 void v8::Integer::CheckCast(v8::Value* that) { |
| 3083 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3096 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3230 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3218 i::Isolate* isolate = NULL; | 3231 i::Isolate* isolate = NULL; |
| 3219 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate(); | 3232 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
| 3220 Utils::ApiCheck(isolate != NULL && | 3233 Utils::ApiCheck(isolate != NULL && |
| 3221 obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), | 3234 obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), |
| 3222 "v8::SymbolObject::Cast()", | 3235 "v8::SymbolObject::Cast()", |
| 3223 "Could not convert to SymbolObject"); | 3236 "Could not convert to SymbolObject"); |
| 3224 } | 3237 } |
| 3225 | 3238 |
| 3226 | 3239 |
| 3240 void v8::Float32x4Object::CheckCast(v8::Value* that) { |
| 3241 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3242 i::Isolate* isolate = NULL; |
| 3243 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
| 3244 Utils::ApiCheck( |
| 3245 isolate != NULL && |
| 3246 obj->HasSpecificClassOf(isolate->heap()->Float32x4_string()), |
| 3247 "v8::Float32x4Object::Cast()", "Could not convert to Float32x4Object"); |
| 3248 } |
| 3249 |
| 3250 |
| 3227 void v8::NumberObject::CheckCast(v8::Value* that) { | 3251 void v8::NumberObject::CheckCast(v8::Value* that) { |
| 3228 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3252 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3229 i::Isolate* isolate = NULL; | 3253 i::Isolate* isolate = NULL; |
| 3230 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate(); | 3254 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
| 3231 Utils::ApiCheck(isolate != NULL && | 3255 Utils::ApiCheck(isolate != NULL && |
| 3232 obj->HasSpecificClassOf(isolate->heap()->Number_string()), | 3256 obj->HasSpecificClassOf(isolate->heap()->Number_string()), |
| 3233 "v8::NumberObject::Cast()", | 3257 "v8::NumberObject::Cast()", |
| 3234 "Could not convert to NumberObject"); | 3258 "Could not convert to NumberObject"); |
| 3235 } | 3259 } |
| 3236 | 3260 |
| (...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6089 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 6113 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
| 6090 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6114 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6091 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6115 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 6092 i::Isolate* isolate = jsvalue->GetIsolate(); | 6116 i::Isolate* isolate = jsvalue->GetIsolate(); |
| 6093 LOG_API(isolate, "SymbolObject::SymbolValue"); | 6117 LOG_API(isolate, "SymbolObject::SymbolValue"); |
| 6094 return Utils::ToLocal( | 6118 return Utils::ToLocal( |
| 6095 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 6119 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
| 6096 } | 6120 } |
| 6097 | 6121 |
| 6098 | 6122 |
| 6123 Local<v8::Value> v8::Float32x4Object::New(Isolate* isolate, |
| 6124 Handle<Float32x4> value) { |
| 6125 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6126 LOG_API(i_isolate, "Float32x4Object::New"); |
| 6127 ENTER_V8(i_isolate); |
| 6128 i::Handle<i::Object> obj = |
| 6129 i::Object::ToObject(i_isolate, Utils::OpenHandle(*value)) |
| 6130 .ToHandleChecked(); |
| 6131 return Utils::ToLocal(obj); |
| 6132 } |
| 6133 |
| 6134 |
| 6135 Local<v8::Float32x4> v8::Float32x4Object::ValueOf() const { |
| 6136 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6137 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 6138 i::Isolate* isolate = jsvalue->GetIsolate(); |
| 6139 LOG_API(isolate, "Float32x4Object::Float32Value"); |
| 6140 return Utils::ToLocal( |
| 6141 i::Handle<i::Float32x4>(i::Float32x4::cast(jsvalue->value()))); |
| 6142 } |
| 6143 |
| 6144 |
| 6099 MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) { | 6145 MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) { |
| 6100 if (std::isnan(time)) { | 6146 if (std::isnan(time)) { |
| 6101 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 6147 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
| 6102 time = std::numeric_limits<double>::quiet_NaN(); | 6148 time = std::numeric_limits<double>::quiet_NaN(); |
| 6103 } | 6149 } |
| 6104 PREPARE_FOR_EXECUTION(context, "Date::New", Value); | 6150 PREPARE_FOR_EXECUTION(context, "Date::New", Value); |
| 6105 Local<Value> result; | 6151 Local<Value> result; |
| 6106 has_pending_exception = | 6152 has_pending_exception = |
| 6107 !ToLocal<Value>(i::Execution::NewDate(isolate, time), &result); | 6153 !ToLocal<Value>(i::Execution::NewDate(isolate, time), &result); |
| 6108 RETURN_ON_FAILED_EXECUTION(Value); | 6154 RETURN_ON_FAILED_EXECUTION(Value); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6940 return Utils::ToLocal(i_isolate->factory()->unscopables_symbol()); | 6986 return Utils::ToLocal(i_isolate->factory()->unscopables_symbol()); |
| 6941 } | 6987 } |
| 6942 | 6988 |
| 6943 | 6989 |
| 6944 Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) { | 6990 Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) { |
| 6945 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6991 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6946 return Utils::ToLocal(i_isolate->factory()->to_string_tag_symbol()); | 6992 return Utils::ToLocal(i_isolate->factory()->to_string_tag_symbol()); |
| 6947 } | 6993 } |
| 6948 | 6994 |
| 6949 | 6995 |
| 6996 Local<Float32x4> v8::Float32x4::New(Isolate* isolate, float w, float x, float y, |
| 6997 float z) { |
| 6998 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6999 LOG_API(i_isolate, "Float32x4::New()"); |
| 7000 ENTER_V8(i_isolate); |
| 7001 i::Handle<i::Float32x4> result = |
| 7002 i_isolate->factory()->NewFloat32x4(w, x, y, z); |
| 7003 return Utils::ToLocal(result); |
| 7004 } |
| 7005 |
| 7006 |
| 6950 Local<Number> v8::Number::New(Isolate* isolate, double value) { | 7007 Local<Number> v8::Number::New(Isolate* isolate, double value) { |
| 6951 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7008 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6952 if (std::isnan(value)) { | 7009 if (std::isnan(value)) { |
| 6953 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 7010 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
| 6954 value = std::numeric_limits<double>::quiet_NaN(); | 7011 value = std::numeric_limits<double>::quiet_NaN(); |
| 6955 } | 7012 } |
| 6956 ENTER_V8(internal_isolate); | 7013 ENTER_V8(internal_isolate); |
| 6957 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 7014 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6958 return Utils::NumberToLocal(result); | 7015 return Utils::NumberToLocal(result); |
| 6959 } | 7016 } |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8513 Address callback_address = | 8570 Address callback_address = |
| 8514 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8571 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8515 VMState<EXTERNAL> state(isolate); | 8572 VMState<EXTERNAL> state(isolate); |
| 8516 ExternalCallbackScope call_scope(isolate, callback_address); | 8573 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8517 callback(info); | 8574 callback(info); |
| 8518 } | 8575 } |
| 8519 | 8576 |
| 8520 | 8577 |
| 8521 } // namespace internal | 8578 } // namespace internal |
| 8522 } // namespace v8 | 8579 } // namespace v8 |
| OLD | NEW |