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

Side by Side Diff: src/objects.cc

Issue 2814683002: [builtins] Implement %TypedArray%.prototype.map in the CSA (Closed)
Patch Set: switched to BIND macro 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
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 17269 matching lines...) Expand 10 before | Expand all | Expand 10 after
17280 17280
17281 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE) 17281 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE)
17282 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE 17282 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE
17283 17283
17284 default: 17284 default:
17285 UNREACHABLE(); 17285 UNREACHABLE();
17286 return 0; 17286 return 0;
17287 } 17287 }
17288 } 17288 }
17289 17289
17290 // static
17291 MaybeHandle<JSTypedArray> JSTypedArray::Create(Isolate* isolate,
17292 Handle<JSFunction> default_ctor,
17293 int argc, Handle<Object>* argv) {
17294 // 1. Let newTypedArray be ? Construct(constructor, argumentList).
17295 Handle<Object> new_obj;
17296 ASSIGN_RETURN_ON_EXCEPTION(
17297 isolate, new_obj, Execution::New(default_ctor, argc, argv), JSTypedArray);
17298
17299 // 2. Perform ? ValidateTypedArray(newTypedArray).
17300 Handle<JSTypedArray> new_array;
17301 ASSIGN_RETURN_ON_EXCEPTION(isolate, new_array,
17302 JSTypedArray::Validate(isolate, new_obj),
17303 JSTypedArray);
17304
17305 // 3. If argumentList is a List of a single Number, then
17306 // If newTypedArray.[[ArrayLength]] < size, throw a TypeError exception.
17307 DCHECK_IMPLIES(argc == 1, argv[0]->IsSmi());
17308 if (argc == 1 && new_array->length_value() < argv[0]->Number()) {
17309 const MessageTemplate::Template message =
17310 MessageTemplate::kTypedArrayTooShort;
17311 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
17312 }
17313
17314 // 4. Return newTypedArray.
17315 return new_array;
17316 }
17317
17318 // static
17319 MaybeHandle<JSTypedArray> JSTypedArray::SpeciesCreate(
17320 Isolate* isolate, Handle<JSTypedArray> exemplar, int argc,
17321 Handle<Object>* argv) {
17322 // 1. Assert: exemplar is an Object that has a [[TypedArrayName]] internal
17323 // slot.
17324 DCHECK(exemplar->IsJSTypedArray());
17325
17326 // 2. Let defaultConstructor be the intrinsic object listed in column one of
17327 // Table 51 for exemplar.[[TypedArrayName]].
17328 Handle<JSFunction> default_ctor = isolate->uint8_array_fun();
17329 switch (exemplar->type()) {
17330 #define TYPED_ARRAY_CTOR(Type, type, TYPE, ctype, size) \
17331 case kExternal##Type##Array: { \
17332 default_ctor = isolate->type##_array_fun(); \
17333 break; \
17334 }
17335
17336 TYPED_ARRAYS(TYPED_ARRAY_CTOR)
17337 #undef TYPED_ARRAY_CTOR
17338 default:
17339 UNREACHABLE();
17340 }
17341
17342 // 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
17343 Handle<Object> ctor;
17344 ASSIGN_RETURN_ON_EXCEPTION(
17345 isolate, ctor,
17346 Object::SpeciesConstructor(isolate, exemplar, default_ctor),
17347 JSTypedArray);
17348
17349 // 4. Return ? TypedArrayCreate(constructor, argumentList).
17350 return Create(isolate, Handle<JSFunction>::cast(ctor), argc, argv);
17351 }
17290 17352
17291 void JSGlobalObject::InvalidatePropertyCell(Handle<JSGlobalObject> global, 17353 void JSGlobalObject::InvalidatePropertyCell(Handle<JSGlobalObject> global,
17292 Handle<Name> name) { 17354 Handle<Name> name) {
17293 DCHECK(!global->HasFastProperties()); 17355 DCHECK(!global->HasFastProperties());
17294 auto dictionary = handle(global->global_dictionary()); 17356 auto dictionary = handle(global->global_dictionary());
17295 int entry = dictionary->FindEntry(name); 17357 int entry = dictionary->FindEntry(name);
17296 if (entry == GlobalDictionary::kNotFound) return; 17358 if (entry == GlobalDictionary::kNotFound) return;
17297 PropertyCell::InvalidateEntry(dictionary, entry); 17359 PropertyCell::InvalidateEntry(dictionary, entry);
17298 } 17360 }
17299 17361
(...skipping 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after
20451 // depend on this. 20513 // depend on this.
20452 return DICTIONARY_ELEMENTS; 20514 return DICTIONARY_ELEMENTS;
20453 } 20515 }
20454 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20516 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20455 return kind; 20517 return kind;
20456 } 20518 }
20457 } 20519 }
20458 20520
20459 } // namespace internal 20521 } // namespace internal
20460 } // namespace v8 20522 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698