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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 2810363003: [builtins] Introduce DeleteProperty builtin (Closed)
Patch Set: fix CallableFor not to create handles Created 3 years, 8 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 | « src/runtime/runtime.h ('k') | 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, 452 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
453 Object::ToObject(isolate, object)); 453 Object::ToObject(isolate, object));
454 Maybe<bool> result = 454 Maybe<bool> result =
455 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode); 455 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode);
456 MAYBE_RETURN(result, isolate->heap()->exception()); 456 MAYBE_RETURN(result, isolate->heap()->exception());
457 return isolate->heap()->ToBoolean(result.FromJust()); 457 return isolate->heap()->ToBoolean(result.FromJust());
458 } 458 }
459 459
460 } // namespace 460 } // namespace
461 461
462 RUNTIME_FUNCTION(Runtime_DeleteProperty) {
463 HandleScope scope(isolate);
464 DCHECK_EQ(3, args.length());
465 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
466 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
467 CONVERT_SMI_ARG_CHECKED(language_mode, 2);
468 return DeleteProperty(isolate, object, key,
469 static_cast<LanguageMode>(language_mode));
470 }
462 471
463 RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { 472 RUNTIME_FUNCTION(Runtime_ShrinkPropertyDictionary) {
464 HandleScope scope(isolate); 473 HandleScope scope(isolate);
465 DCHECK_EQ(2, args.length()); 474 DCHECK_EQ(2, args.length());
466 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 475 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
467 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 476 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
468 return DeleteProperty(isolate, object, key, SLOPPY); 477 Handle<NameDictionary> dictionary(receiver->property_dictionary(), isolate);
478 Handle<NameDictionary> new_properties =
479 NameDictionary::Shrink(dictionary, key);
480 receiver->set_properties(*new_properties);
481 return Smi::kZero;
469 } 482 }
470 483
471
472 RUNTIME_FUNCTION(Runtime_DeleteProperty_Strict) {
473 HandleScope scope(isolate);
474 DCHECK_EQ(2, args.length());
475 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
476 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
477 return DeleteProperty(isolate, object, key, STRICT);
478 }
479
480
481 // ES6 section 12.9.3, operator in. 484 // ES6 section 12.9.3, operator in.
482 RUNTIME_FUNCTION(Runtime_HasProperty) { 485 RUNTIME_FUNCTION(Runtime_HasProperty) {
483 HandleScope scope(isolate); 486 HandleScope scope(isolate);
484 DCHECK_EQ(2, args.length()); 487 DCHECK_EQ(2, args.length());
485 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 488 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
486 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 489 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
487 490
488 // Check that {object} is actually a receiver. 491 // Check that {object} is actually a receiver.
489 if (!object->IsJSReceiver()) { 492 if (!object->IsJSReceiver()) {
490 THROW_NEW_ERROR_RETURN_FAILURE( 493 THROW_NEW_ERROR_RETURN_FAILURE(
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 // While iteration alone may not have observable side-effects, calling 1043 // While iteration alone may not have observable side-effects, calling
1041 // toNumber on an object will. Make sure the arg is not an array of objects. 1044 // toNumber on an object will. Make sure the arg is not an array of objects.
1042 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind(); 1045 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind();
1043 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false); 1046 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false);
1044 1047
1045 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects()); 1048 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects());
1046 } 1049 }
1047 1050
1048 } // namespace internal 1051 } // namespace internal
1049 } // namespace v8 1052 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698