Chromium Code Reviews| 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 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3398 if (self->IsJSObject() && other->IsJSObject()) { | 3398 if (self->IsJSObject() && other->IsJSObject()) { |
| 3399 return *self == *other; | 3399 return *self == *other; |
| 3400 } | 3400 } |
| 3401 auto heap_object = self->IsSmi() ? other : self; | 3401 auto heap_object = self->IsSmi() ? other : self; |
| 3402 auto context = ContextFromHeapObject(heap_object); | 3402 auto context = ContextFromHeapObject(heap_object); |
| 3403 return Equals(context, that).FromMaybe(false); | 3403 return Equals(context, that).FromMaybe(false); |
| 3404 } | 3404 } |
| 3405 | 3405 |
| 3406 | 3406 |
| 3407 bool Value::StrictEquals(Local<Value> that) const { | 3407 bool Value::StrictEquals(Local<Value> that) const { |
| 3408 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3408 auto self = Utils::OpenHandle(this); |
| 3409 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 3409 auto other = Utils::OpenHandle(*that); |
| 3410 if (obj->IsSmi()) { | 3410 return self->StrictEquals(*other); |
| 3411 return other->IsNumber() && obj->Number() == other->Number(); | |
| 3412 } | |
| 3413 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); | |
| 3414 LOG_API(isolate, "StrictEquals"); | |
| 3415 // Must check HeapNumber first, since NaN !== NaN. | |
| 3416 if (obj->IsHeapNumber()) { | |
| 3417 if (!other->IsNumber()) return false; | |
| 3418 double x = obj->Number(); | |
| 3419 double y = other->Number(); | |
| 3420 // Must check explicitly for NaN:s on Windows, but -0 works fine. | |
| 3421 return x == y && !std::isnan(x) && !std::isnan(y); | |
| 3422 } else if (*obj == *other) { // Also covers Booleans. | |
| 3423 return true; | |
| 3424 } else if (obj->IsSmi()) { | |
| 3425 return other->IsNumber() && obj->Number() == other->Number(); | |
| 3426 } else if (obj->IsString()) { | |
| 3427 return other->IsString() && | |
| 3428 i::String::Equals(i::Handle<i::String>::cast(obj), | |
| 3429 i::Handle<i::String>::cast(other)); | |
| 3430 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { | |
| 3431 return other->IsUndefined() || other->IsUndetectableObject(); | |
|
Yang
2015/08/17 07:13:32
This undetectable check is lost. I guess this is i
Benedikt Meurer
2015/08/17 07:59:49
Yes. The code stub has an explicit comment that st
| |
| 3432 } else { | |
| 3433 return false; | |
| 3434 } | |
| 3435 } | 3411 } |
| 3436 | 3412 |
| 3437 | 3413 |
| 3438 bool Value::SameValue(Local<Value> that) const { | 3414 bool Value::SameValue(Local<Value> that) const { |
| 3439 auto self = Utils::OpenHandle(this); | 3415 auto self = Utils::OpenHandle(this); |
| 3440 auto other = Utils::OpenHandle(*that); | 3416 auto other = Utils::OpenHandle(*that); |
| 3441 return self->SameValue(*other); | 3417 return self->SameValue(*other); |
| 3442 } | 3418 } |
| 3443 | 3419 |
| 3444 | 3420 |
| (...skipping 4993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8438 Address callback_address = | 8414 Address callback_address = |
| 8439 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8415 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8440 VMState<EXTERNAL> state(isolate); | 8416 VMState<EXTERNAL> state(isolate); |
| 8441 ExternalCallbackScope call_scope(isolate, callback_address); | 8417 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8442 callback(info); | 8418 callback(info); |
| 8443 } | 8419 } |
| 8444 | 8420 |
| 8445 | 8421 |
| 8446 } // namespace internal | 8422 } // namespace internal |
| 8447 } // namespace v8 | 8423 } // namespace v8 |
| OLD | NEW |