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 2811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2822 value = isolate->factory()->NewNumber(index); | 2822 value = isolate->factory()->NewNumber(index); |
2823 } | 2823 } |
2824 return Utils::Uint32ToLocal(value); | 2824 return Utils::Uint32ToLocal(value); |
2825 } | 2825 } |
2826 return Local<Uint32>(); | 2826 return Local<Uint32>(); |
2827 } | 2827 } |
2828 | 2828 |
2829 | 2829 |
2830 int32_t Value::Int32Value() const { | 2830 int32_t Value::Int32Value() const { |
2831 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2831 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2832 if (obj->IsSmi()) { | 2832 if (obj->IsNumber()) { |
2833 return i::Smi::cast(*obj)->value(); | 2833 return NumberToInt32(*obj); |
2834 } else { | 2834 } else { |
2835 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); | 2835 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
2836 LOG_API(isolate, "Int32Value (slow)"); | 2836 LOG_API(isolate, "Int32Value (slow)"); |
2837 ENTER_V8(isolate); | 2837 ENTER_V8(isolate); |
2838 EXCEPTION_PREAMBLE(isolate); | 2838 EXCEPTION_PREAMBLE(isolate); |
2839 i::Handle<i::Object> num; | 2839 i::Handle<i::Object> num; |
2840 has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num); | 2840 has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num); |
2841 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2841 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
2842 if (num->IsSmi()) { | 2842 if (num->IsSmi()) { |
2843 return i::Smi::cast(*num)->value(); | 2843 return i::Smi::cast(*num)->value(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2923 "Reading from empty handle")) { | 2923 "Reading from empty handle")) { |
2924 return false; | 2924 return false; |
2925 } | 2925 } |
2926 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 2926 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
2927 return obj->SameValue(*other); | 2927 return obj->SameValue(*other); |
2928 } | 2928 } |
2929 | 2929 |
2930 | 2930 |
2931 uint32_t Value::Uint32Value() const { | 2931 uint32_t Value::Uint32Value() const { |
2932 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2932 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2933 if (obj->IsSmi()) { | 2933 if (obj->IsNumber()) { |
2934 return i::Smi::cast(*obj)->value(); | 2934 return NumberToUint32(*obj); |
2935 } else { | 2935 } else { |
2936 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); | 2936 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
2937 LOG_API(isolate, "Uint32Value"); | 2937 LOG_API(isolate, "Uint32Value"); |
2938 ENTER_V8(isolate); | 2938 ENTER_V8(isolate); |
2939 EXCEPTION_PREAMBLE(isolate); | 2939 EXCEPTION_PREAMBLE(isolate); |
2940 i::Handle<i::Object> num; | 2940 i::Handle<i::Object> num; |
2941 has_pending_exception = !i::Execution::ToUint32( | 2941 has_pending_exception = !i::Execution::ToUint32( |
2942 isolate, obj).ToHandle(&num); | 2942 isolate, obj).ToHandle(&num); |
2943 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2943 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
2944 if (num->IsSmi()) { | 2944 if (num->IsSmi()) { |
(...skipping 4649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7594 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7594 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7595 Address callback_address = | 7595 Address callback_address = |
7596 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7596 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7597 VMState<EXTERNAL> state(isolate); | 7597 VMState<EXTERNAL> state(isolate); |
7598 ExternalCallbackScope call_scope(isolate, callback_address); | 7598 ExternalCallbackScope call_scope(isolate, callback_address); |
7599 callback(info); | 7599 callback(info); |
7600 } | 7600 } |
7601 | 7601 |
7602 | 7602 |
7603 } } // namespace v8::internal | 7603 } } // namespace v8::internal |
OLD | NEW |