Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: src/api.cc

Issue 873983003: Add HeapNumber fast path to v8::Value::{Uint,Int}32Value() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698