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

Side by Side Diff: src/objects.cc

Issue 1421413002: Update to ES2015 == semantics for Symbol/SIMD wrappers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: make ordering closer to other clauses Created 5 years, 1 month 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 | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)) 294 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) {
295 .ToHandle(&y)) { 295 continue;
296 } else {
296 return Nothing<bool>(); 297 return Nothing<bool>();
297 } 298 }
298 } else { 299 } else {
299 return Just(false); 300 return Just(false);
300 } 301 }
301 } else if (x->IsString()) { 302 } else if (x->IsString()) {
302 if (y->IsString()) { 303 if (y->IsString()) {
303 return Just( 304 return Just(
304 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y))); 305 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y)));
305 } else if (y->IsNumber()) { 306 } else if (y->IsNumber()) {
306 x = String::ToNumber(Handle<String>::cast(x)); 307 x = String::ToNumber(Handle<String>::cast(x));
307 return Just(NumberEquals(x, y)); 308 return Just(NumberEquals(x, y));
308 } else if (y->IsBoolean()) { 309 } else if (y->IsBoolean()) {
309 x = String::ToNumber(Handle<String>::cast(x)); 310 x = String::ToNumber(Handle<String>::cast(x));
310 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number())); 311 return Just(NumberEquals(*x, Handle<Oddball>::cast(y)->to_number()));
311 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { 312 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
312 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 313 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) {
313 .ToHandle(&y)) { 314 continue;
315 } else {
314 return Nothing<bool>(); 316 return Nothing<bool>();
315 } 317 }
316 } else { 318 } else {
317 return Just(false); 319 return Just(false);
318 } 320 }
319 } else if (x->IsBoolean()) { 321 } else if (x->IsBoolean()) {
320 if (y->IsOddball()) { 322 if (y->IsOddball()) {
321 return Just(x.is_identical_to(y)); 323 return Just(x.is_identical_to(y));
322 } else if (y->IsNumber()) { 324 } else if (y->IsNumber()) {
323 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); 325 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y));
324 } else if (y->IsString()) { 326 } else if (y->IsString()) {
325 y = String::ToNumber(Handle<String>::cast(y)); 327 y = String::ToNumber(Handle<String>::cast(y));
326 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y)); 328 return Just(NumberEquals(Handle<Oddball>::cast(x)->to_number(), *y));
327 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) { 329 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
328 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)) 330 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y))
329 .ToHandle(&y)) { 331 .ToHandle(&y)) {
330 return Nothing<bool>(); 332 return Nothing<bool>();
331 } 333 }
332 x = Oddball::ToNumber(Handle<Oddball>::cast(x)); 334 x = Oddball::ToNumber(Handle<Oddball>::cast(x));
335 continue;
333 } else { 336 } else {
334 return Just(false); 337 return Just(false);
335 } 338 }
336 } else if (x->IsSymbol()) { 339 } else if (x->IsSymbol()) {
337 return Just(x.is_identical_to(y)); 340 if (y->IsSymbol()) {
341 return Just(x.is_identical_to(y));
342 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
343 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) {
344 continue;
345 } else {
346 return Nothing<bool>();
347 }
348 } else {
349 return Just(false);
350 }
338 } else if (x->IsSimd128Value()) { 351 } else if (x->IsSimd128Value()) {
339 if (!y->IsSimd128Value()) return Just(false); 352 if (y->IsSimd128Value()) {
340 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x), 353 return Just(Simd128Value::Equals(Handle<Simd128Value>::cast(x),
341 Handle<Simd128Value>::cast(y))); 354 Handle<Simd128Value>::cast(y)));
355 } else if (y->IsJSReceiver() && !y->IsUndetectableObject()) {
356 if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(y)).ToHandle(&y)) {
357 continue;
358 } else {
359 return Nothing<bool>();
360 }
361 } else {
362 return Just(false);
363 }
342 } else if (x->IsJSReceiver() && !x->IsUndetectableObject()) { 364 } else if (x->IsJSReceiver() && !x->IsUndetectableObject()) {
343 if (y->IsJSReceiver()) { 365 if (y->IsJSReceiver()) {
344 return Just(x.is_identical_to(y)); 366 return Just(x.is_identical_to(y));
345 } else if (y->IsNull() || y->IsSimd128Value() || y->IsSymbol() || 367 } else if (y->IsNull() || y->IsUndefined()) {
346 y->IsUndefined()) {
347 return Just(false); 368 return Just(false);
348 } else if (y->IsBoolean()) { 369 } else if (y->IsBoolean()) {
349 y = Oddball::ToNumber(Handle<Oddball>::cast(y)); 370 y = Oddball::ToNumber(Handle<Oddball>::cast(y));
350 } 371 continue;
351 if (!JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x)).ToHandle(&x)) { 372 } else if (JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(x))
373 .ToHandle(&x)) {
374 continue;
375 } else {
352 return Nothing<bool>(); 376 return Nothing<bool>();
353 } 377 }
354 } else { 378 } else {
355 return Just( 379 return Just(
356 (x->IsNull() || x->IsUndefined() || x->IsUndetectableObject()) && 380 (x->IsNull() || x->IsUndefined() || x->IsUndetectableObject()) &&
357 (y->IsNull() || y->IsUndefined() || y->IsUndetectableObject())); 381 (y->IsNull() || y->IsUndefined() || y->IsUndetectableObject()));
358 } 382 }
383 UNREACHABLE();
359 } 384 }
360 } 385 }
361 386
362 387
363 bool Object::StrictEquals(Object* that) { 388 bool Object::StrictEquals(Object* that) {
364 if (this->IsNumber()) { 389 if (this->IsNumber()) {
365 if (!that->IsNumber()) return false; 390 if (!that->IsNumber()) return false;
366 return NumberEquals(this, that); 391 return NumberEquals(this, that);
367 } else if (this->IsString()) { 392 } else if (this->IsString()) {
368 if (!that->IsString()) return false; 393 if (!that->IsString()) return false;
(...skipping 17546 matching lines...) Expand 10 before | Expand all | Expand 10 after
17915 if (cell->value() != *new_value) { 17940 if (cell->value() != *new_value) {
17916 cell->set_value(*new_value); 17941 cell->set_value(*new_value);
17917 Isolate* isolate = cell->GetIsolate(); 17942 Isolate* isolate = cell->GetIsolate();
17918 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17943 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17919 isolate, DependentCode::kPropertyCellChangedGroup); 17944 isolate, DependentCode::kPropertyCellChangedGroup);
17920 } 17945 }
17921 } 17946 }
17922 17947
17923 } // namespace internal 17948 } // namespace internal
17924 } // namespace v8 17949 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698