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

Side by Side Diff: src/objects.cc

Issue 1764613004: [rutime] Simplify undetectable handling in Object::Equals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // static 285 // static
286 Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) { 286 Maybe<bool> Object::Equals(Handle<Object> x, Handle<Object> y) {
287 while (true) { 287 while (true) {
288 if (x->IsNumber()) { 288 if (x->IsNumber()) {
289 if (y->IsNumber()) { 289 if (y->IsNumber()) {
290 return Just(NumberEquals(x, y)); 290 return Just(NumberEquals(x, y));
291 } else if (y->IsBoolean()) { 291 } else if (y->IsBoolean()) {
292 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); 292 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number()));
293 } else if (y->IsString()) { 293 } else if (y->IsString()) {
294 return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y)))); 294 return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y))));
295 } else if (y->IsJSReceiver() && !y->IsUndetectable()) { 295 } else if (y->IsJSReceiver()) {
296 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 296 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
297 .ToHandle(&y)) { 297 .ToHandle(&y)) {
298 return Nothing<bool>(); 298 return Nothing<bool>();
299 } 299 }
300 } else { 300 } else {
301 return Just(false); 301 return Just(false);
302 } 302 }
303 } else if (x->IsString()) { 303 } else if (x->IsString()) {
304 if (y->IsString()) { 304 if (y->IsString()) {
305 return Just( 305 return Just(
306 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y))); 306 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y)));
307 } else if (y->IsNumber()) { 307 } else if (y->IsNumber()) {
308 x = String::ToNumber(Handle<String>::cast(x)); 308 x = String::ToNumber(Handle<String>::cast(x));
309 return Just(NumberEquals(x, y)); 309 return Just(NumberEquals(x, y));
310 } else if (y->IsBoolean()) { 310 } else if (y->IsBoolean()) {
311 x = String::ToNumber(Handle<String>::cast(x)); 311 x = String::ToNumber(Handle<String>::cast(x));
312 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); 312 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number()));
313 } else if (y->IsJSReceiver() && !y->IsUndetectable()) { 313 } else if (y->IsJSReceiver()) {
314 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 314 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
315 .ToHandle(&y)) { 315 .ToHandle(&y)) {
316 return Nothing<bool>(); 316 return Nothing<bool>();
317 } 317 }
318 } else { 318 } else {
319 return Just(false); 319 return Just(false);
320 } 320 }
321 } else if (x->IsBoolean()) { 321 } else if (x->IsBoolean()) {
322 if (y->IsOddball()) { 322 if (y->IsOddball()) {
323 return Just(x.is_identical_to(y)); 323 return Just(x.is_identical_to(y));
324 } else if (y->IsNumber()) { 324 } else if (y->IsNumber()) {
325 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); 325 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y));
326 } else if (y->IsString()) { 326 } else if (y->IsString()) {
327 y = String::ToNumber(Handle<String>::cast(y)); 327 y = String::ToNumber(Handle<String>::cast(y));
328 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); 328 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y));
329 } else if (y->IsJSReceiver() && !y->IsUndetectable()) { 329 } else if (y->IsJSReceiver()) {
330 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 330 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
331 .ToHandle(&y)) { 331 .ToHandle(&y)) {
332 return Nothing<bool>(); 332 return Nothing<bool>();
333 } 333 }
334 x = Oddball::ToNumber(Handle<Oddball>::cast(x)); 334 x = Oddball::ToNumber(Handle<Oddball>::cast(x));
335 } else { 335 } else {
336 return Just(false); 336 return Just(false);
337 } 337 }
338 } else if (x->IsSymbol()) { 338 } else if (x->IsSymbol()) {
339 if (y->IsSymbol()) { 339 if (y->IsSymbol()) {
340 return Just(x.is_identical_to(y)); 340 return Just(x.is_identical_to(y));
341 } else if (y->IsJSReceiver() && !y->IsUndetectable()) { 341 } else if (y->IsJSReceiver()) {
342 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 342 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
343 .ToHandle(&y)) { 343 .ToHandle(&y)) {
344 return Nothing<bool>(); 344 return Nothing<bool>();
345 } 345 }
346 } else { 346 } else {
347 return Just(false); 347 return Just(false);
348 } 348 }
349 } else if (x->IsSimd128Value()) { 349 } else if (x->IsSimd128Value()) {
350 if (y->IsSimd128Value()) { 350 if (y->IsSimd128Value()) {
351 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x), 351 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x),
352 Handle<Simd128Value>::cast(y))); 352 Handle<Simd128Value>::cast(y)));
353 } else if (y->IsJSReceiver() && !y->IsUndetectable()) { 353 } else if (y->IsJSReceiver()) {
354 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 354 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
355 .ToHandle(&y)) { 355 .ToHandle(&y)) {
356 return Nothing<bool>(); 356 return Nothing<bool>();
357 } 357 }
358 } else { 358 } else {
359 return Just(false); 359 return Just(false);
360 } 360 }
361 } else if (x->IsJSReceiver() && !x->IsUndetectable()) { 361 } else if (x->IsJSReceiver()) {
362 if (y->IsJSReceiver()) { 362 if (y->IsUndetectable()) {
363 return Just(x->IsUndetectable());
364 } else if (y->IsJSReceiver()) {
363 return Just(x.is_identical_to(y)); 365 return Just(x.is_identical_to(y));
364 } else if (y->IsNull() || y->IsUndefined()) {
365 return Just(false);
366 } else if (y->IsBoolean()) { 366 } else if (y->IsBoolean()) {
367 y = Oddball::ToNumber(Handle<Oddball>::cast(y)); 367 y = Oddball::ToNumber(Handle<Oddball>::cast(y));
368 } else if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x)) 368 } else if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x))
369 .ToHandle(&x)) { 369 .ToHandle(&x)) {
370 return Nothing<bool>(); 370 return Nothing<bool>();
371 } 371 }
372 } else { 372 } else {
373 return Just(x->IsUndetectable() && y->IsUndetectable()); 373 return Just(x->IsUndetectable() && y->IsUndetectable());
374 } 374 }
375 } 375 }
(...skipping 19388 matching lines...) Expand 10 before | Expand all | Expand 10 after
19764 if (cell->value() != *new_value) { 19764 if (cell->value() != *new_value) {
19765 cell->set_value(*new_value); 19765 cell->set_value(*new_value);
19766 Isolate* isolate = cell->GetIsolate(); 19766 Isolate* isolate = cell->GetIsolate();
19767 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19767 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19768 isolate, DependentCode::kPropertyCellChangedGroup); 19768 isolate, DependentCode::kPropertyCellChangedGroup);
19769 } 19769 }
19770 } 19770 }
19771 19771
19772 } // namespace internal 19772 } // namespace internal
19773 } // namespace v8 19773 } // namespace v8
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