| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { | 284 Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { |
| 285 while (true) { | 285 while (true) { |
| 286 if (x->IsNumber()) { | 286 if (x->IsNumber()) { |
| 287 if (y->IsNumber()) { | 287 if (y->IsNumber()) { |
| 288 return Just(NumberEquals(x, y)); | 288 return Just(NumberEquals(x, y)); |
| 289 } else if (y->IsBoolean()) { | 289 } else if (y->IsBoolean()) { |
| 290 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); | 290 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); |
| 291 } else if (y->IsString()) { | 291 } else if (y->IsString()) { |
| 292 return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y)))); | 292 return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y)))); |
| 293 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { | 293 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { |
| 294 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { | 294 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) |
| 295 continue; | 295 .ToHandle(&y)) { |
| 296 } else { | |
| 297 return Nothing<bool>(); | 296 return Nothing<bool>(); |
| 298 } | 297 } |
| 299 } else { | 298 } else { |
| 300 return Just(false); | 299 return Just(false); |
| 301 } | 300 } |
| 302 } else if (x->IsString()) { | 301 } else if (x->IsString()) { |
| 303 if (y->IsString()) { | 302 if (y->IsString()) { |
| 304 return Just( | 303 return Just( |
| 305 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y))); | 304 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y))); |
| 306 } else if (y->IsNumber()) { | 305 } else if (y->IsNumber()) { |
| 307 x = String::ToNumber(Handle<String>::cast(x)); | 306 x = String::ToNumber(Handle<String>::cast(x)); |
| 308 return Just(NumberEquals(x, y)); | 307 return Just(NumberEquals(x, y)); |
| 309 } else if (y->IsBoolean()) { | 308 } else if (y->IsBoolean()) { |
| 310 x = String::ToNumber(Handle<String>::cast(x)); | 309 x = String::ToNumber(Handle<String>::cast(x)); |
| 311 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); | 310 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); |
| 312 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { | 311 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { |
| 313 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { | 312 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) |
| 314 continue; | 313 .ToHandle(&y)) { |
| 315 } else { | |
| 316 return Nothing<bool>(); | 314 return Nothing<bool>(); |
| 317 } | 315 } |
| 318 } else { | 316 } else { |
| 319 return Just(false); | 317 return Just(false); |
| 320 } | 318 } |
| 321 } else if (x->IsBoolean()) { | 319 } else if (x->IsBoolean()) { |
| 322 if (y->IsOddball()) { | 320 if (y->IsOddball()) { |
| 323 return Just(x.is_identical_to(y)); | 321 return Just(x.is_identical_to(y)); |
| 324 } else if (y->IsNumber()) { | 322 } else if (y->IsNumber()) { |
| 325 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); | 323 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); |
| 326 } else if (y->IsString()) { | 324 } else if (y->IsString()) { |
| 327 y = String::ToNumber(Handle<String>::cast(y)); | 325 y = String::ToNumber(Handle<String>::cast(y)); |
| 328 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); | 326 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); |
| 329 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { | 327 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { |
| 330 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) | 328 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) |
| 331 .ToHandle(&y)) { | 329 .ToHandle(&y)) { |
| 332 return Nothing<bool>(); | 330 return Nothing<bool>(); |
| 333 } | 331 } |
| 334 x = Oddball::ToNumber(Handle<Oddball>::cast(x)); | 332 x = Oddball::ToNumber(Handle<Oddball>::cast(x)); |
| 335 continue; | |
| 336 } else { | 333 } else { |
| 337 return Just(false); | 334 return Just(false); |
| 338 } | 335 } |
| 339 } else if (x->IsSymbol()) { | 336 } else if (x->IsSymbol()) { |
| 340 if (y->IsSymbol()) { | 337 if (y->IsSymbol()) { |
| 341 return Just(x.is_identical_to(y)); | 338 return Just(x.is_identical_to(y)); |
| 342 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { | 339 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { |
| 343 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { | 340 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) |
| 344 continue; | 341 .ToHandle(&y)) { |
| 345 } else { | |
| 346 return Nothing<bool>(); | 342 return Nothing<bool>(); |
| 347 } | 343 } |
| 348 } else { | 344 } else { |
| 349 return Just(false); | 345 return Just(false); |
| 350 } | 346 } |
| 351 } else if (x->IsSimd128Value()) { | 347 } else if (x->IsSimd128Value()) { |
| 352 if (y->IsSimd128Value()) { | 348 if (y->IsSimd128Value()) { |
| 353 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x), | 349 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x), |
| 354 Handle<Simd128Value>::cast(y))); | 350 Handle<Simd128Value>::cast(y))); |
| 355 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { | 351 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { |
| 356 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) { | 352 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) |
| 357 continue; | 353 .ToHandle(&y)) { |
| 358 } else { | |
| 359 return Nothing<bool>(); | 354 return Nothing<bool>(); |
| 360 } | 355 } |
| 361 } else { | 356 } else { |
| 362 return Just(false); | 357 return Just(false); |
| 363 } | 358 } |
| 364 } else if (x->IsJSReceiver() && !x->IsUndetectableObject()) { | 359 } else if (x->IsJSReceiver() && !x->IsUndetectableObject()) { |
| 365 if (y->IsJSReceiver()) { | 360 if (y->IsJSReceiver()) { |
| 366 return Just(x.is_identical_to(y)); | 361 return Just(x.is_identical_to(y)); |
| 367 } else if (y->IsNull() || y->IsUndefined()) { | 362 } else if (y->IsNull() || y->IsUndefined()) { |
| 368 return Just(false); | 363 return Just(false); |
| 369 } else if (y->IsBoolean()) { | 364 } else if (y->IsBoolean()) { |
| 370 y = Oddball::ToNumber(Handle<Oddball>::cast(y)); | 365 y = Oddball::ToNumber(Handle<Oddball>::cast(y)); |
| 371 continue; | 366 } else if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x)) |
| 372 } else if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x)) | 367 .ToHandle(&x)) { |
| 373 .ToHandle(&x)) { | |
| 374 continue; | |
| 375 } else { | |
| 376 return Nothing<bool>(); | 368 return Nothing<bool>(); |
| 377 } | 369 } |
| 378 } else { | 370 } else { |
| 379 return Just( | 371 return Just( |
| 380 (x->IsNull() || x->IsUndefined() || x->IsUndetectableObject()) && | 372 (x->IsNull() || x->IsUndefined() || x->IsUndetectableObject()) && |
| 381 (y->IsNull() || y->IsUndefined() || y->IsUndetectableObject())); | 373 (y->IsNull() || y->IsUndefined() || y->IsUndetectableObject())); |
| 382 } | 374 } |
| 383 UNREACHABLE(); | |
| 384 } | 375 } |
| 385 } | 376 } |
| 386 | 377 |
| 387 | 378 |
| 388 bool Object::StrictEquals(Object* that) { | 379 bool Object::StrictEquals(Object* that) { |
| 389 if (this->IsNumber()) { | 380 if (this->IsNumber()) { |
| 390 if (!that->IsNumber()) return false; | 381 if (!that->IsNumber()) return false; |
| 391 return NumberEquals(this, that); | 382 return NumberEquals(this, that); |
| 392 } else if (this->IsString()) { | 383 } else if (this->IsString()) { |
| 393 if (!that->IsString()) return false; | 384 if (!that->IsString()) return false; |
| (...skipping 17546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17940 if (cell->value() != *new_value) { | 17931 if (cell->value() != *new_value) { |
| 17941 cell->set_value(*new_value); | 17932 cell->set_value(*new_value); |
| 17942 Isolate* isolate = cell->GetIsolate(); | 17933 Isolate* isolate = cell->GetIsolate(); |
| 17943 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17934 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17944 isolate, DependentCode::kPropertyCellChangedGroup); | 17935 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17945 } | 17936 } |
| 17946 } | 17937 } |
| 17947 | 17938 |
| 17948 } // namespace internal | 17939 } // namespace internal |
| 17949 } // namespace v8 | 17940 } // namespace v8 |
| OLD | NEW |