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

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

Issue 2539093002: [runtime] Port simple String.prototype.indexOf cases to TF Builtin (Closed)
Patch Set: merging with master Created 4 years 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-internal.cc ('k') | src/runtime/runtime-proxy.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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 LookupIterator it = LookupIterator::PropertyOrElement( 126 LookupIterator it = LookupIterator::PropertyOrElement(
127 isolate, receiver, key, &success, LookupIterator::OWN); 127 isolate, receiver, key, &success, LookupIterator::OWN);
128 if (!success) return Nothing<bool>(); 128 if (!success) return Nothing<bool>();
129 129
130 return JSReceiver::DeleteProperty(&it, language_mode); 130 return JSReceiver::DeleteProperty(&it, language_mode);
131 } 131 }
132 132
133 // ES6 19.1.3.2 133 // ES6 19.1.3.2
134 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) { 134 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
135 HandleScope scope(isolate); 135 HandleScope scope(isolate);
136 Handle<Object> property = args.at<Object>(1); 136 Handle<Object> property = args.at(1);
137 137
138 Handle<Name> key; 138 Handle<Name> key;
139 uint32_t index; 139 uint32_t index;
140 bool key_is_array_index = property->ToArrayIndex(&index); 140 bool key_is_array_index = property->ToArrayIndex(&index);
141 141
142 if (!key_is_array_index) { 142 if (!key_is_array_index) {
143 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key, 143 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
144 Object::ToName(isolate, property)); 144 Object::ToName(isolate, property));
145 key_is_array_index = key->AsArrayIndex(&index); 145 key_is_array_index = key->AsArrayIndex(&index);
146 } 146 }
147 147
148 Handle<Object> object = args.at<Object>(0); 148 Handle<Object> object = args.at(0);
149 149
150 if (object->IsJSObject()) { 150 if (object->IsJSObject()) {
151 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); 151 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
152 // Fast case: either the key is a real named property or it is not 152 // Fast case: either the key is a real named property or it is not
153 // an array index and there are no interceptors or hidden 153 // an array index and there are no interceptors or hidden
154 // prototypes. 154 // prototypes.
155 // TODO(jkummerow): Make JSReceiver::HasOwnProperty fast enough to 155 // TODO(jkummerow): Make JSReceiver::HasOwnProperty fast enough to
156 // handle all cases directly (without this custom fast path). 156 // handle all cases directly (without this custom fast path).
157 { 157 {
158 LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR; 158 LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 return isolate->heap()->false_value(); 207 return isolate->heap()->false_value();
208 } 208 }
209 209
210 // ES6 section 19.1.2.2 Object.create ( O [ , Properties ] ) 210 // ES6 section 19.1.2.2 Object.create ( O [ , Properties ] )
211 // TODO(verwaest): Support the common cases with precached map directly in 211 // TODO(verwaest): Support the common cases with precached map directly in
212 // an Object.create stub. 212 // an Object.create stub.
213 RUNTIME_FUNCTION(Runtime_ObjectCreate) { 213 RUNTIME_FUNCTION(Runtime_ObjectCreate) {
214 HandleScope scope(isolate); 214 HandleScope scope(isolate);
215 Handle<Object> prototype = args.at<Object>(0); 215 Handle<Object> prototype = args.at(0);
216 if (!prototype->IsNull(isolate) && !prototype->IsJSReceiver()) { 216 if (!prototype->IsNull(isolate) && !prototype->IsJSReceiver()) {
217 THROW_NEW_ERROR_RETURN_FAILURE( 217 THROW_NEW_ERROR_RETURN_FAILURE(
218 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype)); 218 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, prototype));
219 } 219 }
220 220
221 // Generate the map with the specified {prototype} based on the Object 221 // Generate the map with the specified {prototype} based on the Object
222 // function's initial map from the current native context. 222 // function's initial map from the current native context.
223 // TODO(bmeurer): Use a dedicated cache for Object.create; think about 223 // TODO(bmeurer): Use a dedicated cache for Object.create; think about
224 // slack tracking for Object.create. 224 // slack tracking for Object.create.
225 Handle<Map> map(isolate->native_context()->object_function()->initial_map(), 225 Handle<Map> map(isolate->native_context()->object_function()->initial_map(),
(...skipping 29 matching lines...) Expand all
255 object_properties = 255 object_properties =
256 NameDictionary::New(isolate, NameDictionary::kInitialCapacity); 256 NameDictionary::New(isolate, NameDictionary::kInitialCapacity);
257 } 257 }
258 // Actually allocate the object. 258 // Actually allocate the object.
259 Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map); 259 Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map);
260 if (is_dictionary_map) { 260 if (is_dictionary_map) {
261 object->set_properties(*object_properties); 261 object->set_properties(*object_properties);
262 } 262 }
263 263
264 // Define the properties if properties was specified and is not undefined. 264 // Define the properties if properties was specified and is not undefined.
265 Handle<Object> properties = args.at<Object>(1); 265 Handle<Object> properties = args.at(1);
266 if (!properties->IsUndefined(isolate)) { 266 if (!properties->IsUndefined(isolate)) {
267 RETURN_FAILURE_ON_EXCEPTION( 267 RETURN_FAILURE_ON_EXCEPTION(
268 isolate, JSReceiver::DefineProperties(isolate, object, properties)); 268 isolate, JSReceiver::DefineProperties(isolate, object, properties));
269 } 269 }
270 270
271 return *object; 271 return *object;
272 } 272 }
273 273
274 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, 274 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
275 Handle<Object> object, 275 Handle<Object> object,
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 if (!success) return isolate->heap()->exception(); 957 if (!success) return isolate->heap()->exception();
958 MAYBE_RETURN( 958 MAYBE_RETURN(
959 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), 959 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR),
960 isolate->heap()->exception()); 960 isolate->heap()->exception());
961 return *value; 961 return *value;
962 } 962 }
963 963
964 964
965 } // namespace internal 965 } // namespace internal
966 } // namespace v8 966 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | src/runtime/runtime-proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698