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

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

Issue 1295433002: [runtime] Remove useless IN builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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-numbers.cc ('k') | test/cctest/compiler/test-run-inlining.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/v8.h" 5 #include "src/v8.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/messages.h" 10 #include "src/messages.h"
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // Well, there is one exception: Handle [] on strings. 772 // Well, there is one exception: Handle [] on strings.
773 Handle<String> string = Handle<String>::cast(object); 773 Handle<String> string = Handle<String>::cast(object);
774 if (index < static_cast<uint32_t>(string->length())) { 774 if (index < static_cast<uint32_t>(string->length())) {
775 return isolate->heap()->true_value(); 775 return isolate->heap()->true_value();
776 } 776 }
777 } 777 }
778 return isolate->heap()->false_value(); 778 return isolate->heap()->false_value();
779 } 779 }
780 780
781 781
782 // ES6 section 12.9.3, operator in.
782 RUNTIME_FUNCTION(Runtime_HasProperty) { 783 RUNTIME_FUNCTION(Runtime_HasProperty) {
783 HandleScope scope(isolate); 784 HandleScope scope(isolate);
784 DCHECK(args.length() == 2); 785 DCHECK_EQ(2, args.length());
785 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 786 CONVERT_ARG_HANDLE_CHECKED(Object, key, 0);
786 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 787 CONVERT_ARG_HANDLE_CHECKED(Object, object, 1);
787 788
788 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, key); 789 // Check that {object} is actually a receiver.
790 if (!object->IsJSReceiver()) {
791 THROW_NEW_ERROR_RETURN_FAILURE(
792 isolate,
793 NewTypeError(MessageTemplate::kInvalidInOperatorUse, key, object));
794 }
795 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
796
797 // Check for fast element case.
798 uint32_t index = 0;
799 if (key->ToArrayIndex(&index)) {
800 Maybe<bool> maybe = JSReceiver::HasElement(receiver, index);
801 if (!maybe.IsJust()) return isolate->heap()->exception();
802 return isolate->heap()->ToBoolean(maybe.FromJust());
803 }
804
805 // Convert {key} to a Name first.
806 Handle<Name> name;
807 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
808 Runtime::ToName(isolate, key));
809
810 // Lookup property by {name} on {receiver}.
811 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name);
Yang 2015/08/13 12:07:37 This code is duplicate to v8::Object::Has. Maybe w
Benedikt Meurer 2015/08/13 12:11:13 Mhm, yeah, there's moar code duplication with api.
789 if (!maybe.IsJust()) return isolate->heap()->exception(); 812 if (!maybe.IsJust()) return isolate->heap()->exception();
790 return isolate->heap()->ToBoolean(maybe.FromJust()); 813 return isolate->heap()->ToBoolean(maybe.FromJust());
791 } 814 }
792
793
794 RUNTIME_FUNCTION(Runtime_HasElement) {
795 HandleScope scope(isolate);
796 DCHECK(args.length() == 2);
797 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
798 CONVERT_SMI_ARG_CHECKED(index, 1);
799
800 Maybe<bool> maybe = JSReceiver::HasElement(receiver, index);
801 if (!maybe.IsJust()) return isolate->heap()->exception();
802 return isolate->heap()->ToBoolean(maybe.FromJust());
803 }
804 815
805 816
806 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { 817 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) {
807 HandleScope scope(isolate); 818 HandleScope scope(isolate);
808 DCHECK(args.length() == 2); 819 DCHECK(args.length() == 2);
809 820
810 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 821 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
811 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 822 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
812 823
813 Maybe<PropertyAttributes> maybe = 824 Maybe<PropertyAttributes> maybe =
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 Handle<JSReceiver> receiver; 1472 Handle<JSReceiver> receiver;
1462 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { 1473 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) {
1463 return *receiver; 1474 return *receiver;
1464 } 1475 }
1465 THROW_NEW_ERROR_RETURN_FAILURE( 1476 THROW_NEW_ERROR_RETURN_FAILURE(
1466 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); 1477 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject));
1467 } 1478 }
1468 1479
1469 } // namespace internal 1480 } // namespace internal
1470 } // namespace v8 1481 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-numbers.cc ('k') | test/cctest/compiler/test-run-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698