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

Side by Side Diff: src/api.cc

Issue 691513005: remove some isolate::currents from api.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years 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 | Annotate | Revision Log
« 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 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 if (num->IsSmi()) { 2889 if (num->IsSmi()) {
2890 return i::Smi::cast(*num)->value(); 2890 return i::Smi::cast(*num)->value();
2891 } else { 2891 } else {
2892 return static_cast<int32_t>(num->Number()); 2892 return static_cast<int32_t>(num->Number());
2893 } 2893 }
2894 } 2894 }
2895 } 2895 }
2896 2896
2897 2897
2898 bool Value::Equals(Handle<Value> that) const { 2898 bool Value::Equals(Handle<Value> that) const {
2899 i::Isolate* isolate = i::Isolate::Current();
2900 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); 2899 i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
2900 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2901 if (obj->IsSmi() && other->IsSmi()) {
2902 return obj->Number() == other->Number();
2903 }
2904 i::Object* ho = obj->IsSmi() ? *other : *obj;
2905 i::Isolate* isolate = i::HeapObject::cast(ho)->GetIsolate();
2901 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(), 2906 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
2902 "v8::Value::Equals()", 2907 "v8::Value::Equals()",
2903 "Reading from empty handle")) { 2908 "Reading from empty handle")) {
2904 return false; 2909 return false;
2905 } 2910 }
2906 LOG_API(isolate, "Equals"); 2911 LOG_API(isolate, "Equals");
2907 ENTER_V8(isolate); 2912 ENTER_V8(isolate);
2908 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2909 // If both obj and other are JSObjects, we'd better compare by identity 2913 // If both obj and other are JSObjects, we'd better compare by identity
2910 // immediately when going into JS builtin. The reason is Invoke 2914 // immediately when going into JS builtin. The reason is Invoke
2911 // would overwrite global object receiver with global proxy. 2915 // would overwrite global object receiver with global proxy.
2912 if (obj->IsJSObject() && other->IsJSObject()) { 2916 if (obj->IsJSObject() && other->IsJSObject()) {
2913 return *obj == *other; 2917 return *obj == *other;
2914 } 2918 }
2915 i::Handle<i::Object> args[] = { other }; 2919 i::Handle<i::Object> args[] = { other };
2916 EXCEPTION_PREAMBLE(isolate); 2920 EXCEPTION_PREAMBLE(isolate);
2917 i::Handle<i::Object> result; 2921 i::Handle<i::Object> result;
2918 has_pending_exception = 2922 has_pending_exception =
2919 !CallV8HeapFunction(isolate, "EQUALS", obj, arraysize(args), args) 2923 !CallV8HeapFunction(isolate, "EQUALS", obj, arraysize(args), args)
2920 .ToHandle(&result); 2924 .ToHandle(&result);
2921 EXCEPTION_BAILOUT_CHECK(isolate, false); 2925 EXCEPTION_BAILOUT_CHECK(isolate, false);
2922 return *result == i::Smi::FromInt(i::EQUAL); 2926 return *result == i::Smi::FromInt(i::EQUAL);
2923 } 2927 }
2924 2928
2925 2929
2926 bool Value::StrictEquals(Handle<Value> that) const { 2930 bool Value::StrictEquals(Handle<Value> that) const {
2927 i::Isolate* isolate = i::Isolate::Current();
2928 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); 2931 i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
2932 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2933 if (obj->IsSmi()) {
2934 return other->IsNumber() && obj->Number() == other->Number();
2935 }
2936 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2929 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(), 2937 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
2930 "v8::Value::StrictEquals()", 2938 "v8::Value::StrictEquals()",
2931 "Reading from empty handle")) { 2939 "Reading from empty handle")) {
2932 return false; 2940 return false;
2933 } 2941 }
2934 LOG_API(isolate, "StrictEquals"); 2942 LOG_API(isolate, "StrictEquals");
2935 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2936 // Must check HeapNumber first, since NaN !== NaN. 2943 // Must check HeapNumber first, since NaN !== NaN.
2937 if (obj->IsHeapNumber()) { 2944 if (obj->IsHeapNumber()) {
2938 if (!other->IsNumber()) return false; 2945 if (!other->IsNumber()) return false;
2939 double x = obj->Number(); 2946 double x = obj->Number();
2940 double y = other->Number(); 2947 double y = other->Number();
2941 // Must check explicitly for NaN:s on Windows, but -0 works fine. 2948 // Must check explicitly for NaN:s on Windows, but -0 works fine.
2942 return x == y && !std::isnan(x) && !std::isnan(y); 2949 return x == y && !std::isnan(x) && !std::isnan(y);
2943 } else if (*obj == *other) { // Also covers Booleans. 2950 } else if (*obj == *other) { // Also covers Booleans.
2944 return true; 2951 return true;
2945 } else if (obj->IsSmi()) { 2952 } else if (obj->IsSmi()) {
(...skipping 4712 matching lines...) Expand 10 before | Expand all | Expand 10 after
7658 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7665 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7659 Address callback_address = 7666 Address callback_address =
7660 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7667 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7661 VMState<EXTERNAL> state(isolate); 7668 VMState<EXTERNAL> state(isolate);
7662 ExternalCallbackScope call_scope(isolate, callback_address); 7669 ExternalCallbackScope call_scope(isolate, callback_address);
7663 callback(info); 7670 callback(info);
7664 } 7671 }
7665 7672
7666 7673
7667 } } // namespace v8::internal 7674 } } // 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