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

Side by Side Diff: src/objects.cc

Issue 2697013009: Move ArrayBuffer.prototype.slice implementation to C++ (Closed)
Patch Set: Created 3 years, 10 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
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 <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 } else { 2319 } else {
2320 if (!constructor->IsConstructor()) { 2320 if (!constructor->IsConstructor()) {
2321 THROW_NEW_ERROR(isolate, 2321 THROW_NEW_ERROR(isolate,
2322 NewTypeError(MessageTemplate::kSpeciesNotConstructor), 2322 NewTypeError(MessageTemplate::kSpeciesNotConstructor),
2323 Object); 2323 Object);
2324 } 2324 }
2325 return constructor; 2325 return constructor;
2326 } 2326 }
2327 } 2327 }
2328 2328
2329 // ES6 section 7.3.20 SpeciesConstructor ( O, defaultConstructor )
2330 MUST_USE_RESULT MaybeHandle<Object> Object::SpeciesConstructor(
2331 Isolate* isolate, Handle<JSReceiver> recv,
2332 Handle<JSFunction> default_ctor) {
2333 Handle<Object> ctor_obj;
2334 ASSIGN_RETURN_ON_EXCEPTION(
2335 isolate, ctor_obj,
2336 JSObject::GetProperty(recv, isolate->factory()->constructor_string()),
2337 Object);
2338
2339 if (ctor_obj->IsUndefined(isolate)) return default_ctor;
2340
2341 if (!ctor_obj->IsJSReceiver()) {
2342 THROW_NEW_ERROR(isolate,
2343 NewTypeError(MessageTemplate::kConstructorNotReceiver),
2344 Object);
2345 }
2346
2347 Handle<JSReceiver> ctor = Handle<JSReceiver>::cast(ctor_obj);
2348
2349 Handle<Object> species;
2350 ASSIGN_RETURN_ON_EXCEPTION(
2351 isolate, species,
2352 JSObject::GetProperty(ctor, isolate->factory()->species_symbol()),
2353 Object);
2354
2355 if (species->IsNullOrUndefined(isolate)) {
2356 return default_ctor;
2357 }
2358
2359 if (species->IsConstructor()) return species;
2360
2361 THROW_NEW_ERROR(
2362 isolate, NewTypeError(MessageTemplate::kSpeciesNotConstructor), Object);
2363 }
2364
2329 bool Object::IterationHasObservableEffects() { 2365 bool Object::IterationHasObservableEffects() {
2330 // Check that this object is an array. 2366 // Check that this object is an array.
2331 if (!IsJSArray()) return true; 2367 if (!IsJSArray()) return true;
2332 JSArray* spread_array = JSArray::cast(this); 2368 JSArray* spread_array = JSArray::cast(this);
2333 Isolate* isolate = spread_array->GetIsolate(); 2369 Isolate* isolate = spread_array->GetIsolate();
2334 2370
2335 // Check that we have the original ArrayPrototype. 2371 // Check that we have the original ArrayPrototype.
2336 JSObject* array_proto = JSObject::cast(spread_array->map()->prototype()); 2372 JSObject* array_proto = JSObject::cast(spread_array->map()->prototype());
2337 if (!isolate->is_initial_array_prototype(array_proto)) return true; 2373 if (!isolate->is_initial_array_prototype(array_proto)) return true;
2338 2374
(...skipping 17723 matching lines...) Expand 10 before | Expand all | Expand 10 after
20062 // depend on this. 20098 // depend on this.
20063 return DICTIONARY_ELEMENTS; 20099 return DICTIONARY_ELEMENTS;
20064 } 20100 }
20065 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20101 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20066 return kind; 20102 return kind;
20067 } 20103 }
20068 } 20104 }
20069 20105
20070 } // namespace internal 20106 } // namespace internal
20071 } // namespace v8 20107 } // namespace v8
OLDNEW
« src/builtins/builtins-arraybuffer.cc ('K') | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698