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 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3358 return Local<Uint32>(); | 3358 return Local<Uint32>(); |
3359 } | 3359 } |
3360 auto context = ContextFromHeapObject(self); | 3360 auto context = ContextFromHeapObject(self); |
3361 RETURN_TO_LOCAL_UNCHECKED(ToArrayIndex(context), Uint32); | 3361 RETURN_TO_LOCAL_UNCHECKED(ToArrayIndex(context), Uint32); |
3362 } | 3362 } |
3363 | 3363 |
3364 | 3364 |
3365 Maybe<bool> Value::Equals(Local<Context> context, Local<Value> that) const { | 3365 Maybe<bool> Value::Equals(Local<Context> context, Local<Value> that) const { |
3366 auto self = Utils::OpenHandle(this); | 3366 auto self = Utils::OpenHandle(this); |
3367 auto other = Utils::OpenHandle(*that); | 3367 auto other = Utils::OpenHandle(*that); |
3368 if (self->IsSmi() && other->IsSmi()) { | 3368 return i::Object::Equals(self, other); |
3369 return Just(self->Number() == other->Number()); | |
3370 } | |
3371 if (self->IsJSObject() && other->IsJSObject()) { | |
3372 return Just(*self == *other); | |
3373 } | |
3374 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Value::Equals()", bool); | |
3375 i::Handle<i::Object> args[] = { other }; | |
3376 i::Handle<i::JSFunction> fun = isolate->equals_builtin(); | |
3377 i::Handle<i::Object> result; | |
3378 has_pending_exception = | |
3379 !i::Execution::Call(isolate, fun, self, arraysize(args), args) | |
3380 .ToHandle(&result); | |
3381 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | |
3382 return Just(*result == i::Smi::FromInt(i::EQUAL)); | |
3383 } | 3369 } |
3384 | 3370 |
3385 | 3371 |
3386 bool Value::Equals(Local<Value> that) const { | 3372 bool Value::Equals(Local<Value> that) const { |
3387 auto self = Utils::OpenHandle(this); | 3373 auto self = Utils::OpenHandle(this); |
3388 auto other = Utils::OpenHandle(*that); | 3374 auto other = Utils::OpenHandle(*that); |
3389 if (self->IsSmi() && other->IsSmi()) { | 3375 if (self->IsSmi() && other->IsSmi()) { |
3390 return self->Number() == other->Number(); | 3376 return self->Number() == other->Number(); |
3391 } | 3377 } |
3392 if (self->IsJSObject() && other->IsJSObject()) { | 3378 if (self->IsJSObject() && other->IsJSObject()) { |
(...skipping 5008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8401 Address callback_address = | 8387 Address callback_address = |
8402 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8388 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8403 VMState<EXTERNAL> state(isolate); | 8389 VMState<EXTERNAL> state(isolate); |
8404 ExternalCallbackScope call_scope(isolate, callback_address); | 8390 ExternalCallbackScope call_scope(isolate, callback_address); |
8405 callback(info); | 8391 callback(info); |
8406 } | 8392 } |
8407 | 8393 |
8408 | 8394 |
8409 } // namespace internal | 8395 } // namespace internal |
8410 } // namespace v8 | 8396 } // namespace v8 |
OLD | NEW |