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 2814683002: [builtins] Implement %TypedArray%.prototype.map in the CSA (Closed)
Patch Set: added todo Created 3 years, 7 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/objects.h ('k') | src/runtime/runtime.h » ('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 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 17174 matching lines...) Expand 10 before | Expand all | Expand 10 after
17185 17185
17186 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE) 17186 TYPED_ARRAYS(INSTANCE_TYPE_TO_ELEMENT_SIZE)
17187 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE 17187 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE
17188 17188
17189 default: 17189 default:
17190 UNREACHABLE(); 17190 UNREACHABLE();
17191 return 0; 17191 return 0;
17192 } 17192 }
17193 } 17193 }
17194 17194
17195 // static
17196 MaybeHandle<JSTypedArray> JSTypedArray::Create(Isolate* isolate,
17197 Handle<JSFunction> default_ctor,
17198 int argc, Handle<Object>* argv,
17199 const char* method_name) {
17200 // 1. Let newTypedArray be ? Construct(constructor, argumentList).
17201 Handle<Object> new_obj;
17202 ASSIGN_RETURN_ON_EXCEPTION(
17203 isolate, new_obj, Execution::New(default_ctor, argc, argv), JSTypedArray);
17204
17205 // 2. Perform ? ValidateTypedArray(newTypedArray).
17206 Handle<JSTypedArray> new_array;
17207 ASSIGN_RETURN_ON_EXCEPTION(
17208 isolate, new_array, JSTypedArray::Validate(isolate, new_obj, method_name),
17209 JSTypedArray);
17210
17211 // 3. If argumentList is a List of a single Number, then
17212 // If newTypedArray.[[ArrayLength]] < size, throw a TypeError exception.
17213 DCHECK_IMPLIES(argc == 1, argv[0]->IsSmi());
17214 if (argc == 1 && new_array->length_value() < argv[0]->Number()) {
17215 const MessageTemplate::Template message =
17216 MessageTemplate::kTypedArrayTooShort;
17217 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
17218 }
17219
17220 // 4. Return newTypedArray.
17221 return new_array;
17222 }
17223
17224 // static
17225 MaybeHandle<JSTypedArray> JSTypedArray::SpeciesCreate(
17226 Isolate* isolate, Handle<JSTypedArray> exemplar, int argc,
17227 Handle<Object>* argv, const char* method_name) {
17228 // 1. Assert: exemplar is an Object that has a [[TypedArrayName]] internal
17229 // slot.
17230 DCHECK(exemplar->IsJSTypedArray());
17231
17232 // 2. Let defaultConstructor be the intrinsic object listed in column one of
17233 // Table 51 for exemplar.[[TypedArrayName]].
17234 Handle<JSFunction> default_ctor = isolate->uint8_array_fun();
17235 switch (exemplar->type()) {
17236 #define TYPED_ARRAY_CTOR(Type, type, TYPE, ctype, size) \
17237 case kExternal##Type##Array: { \
17238 default_ctor = isolate->type##_array_fun(); \
17239 break; \
17240 }
17241
17242 TYPED_ARRAYS(TYPED_ARRAY_CTOR)
17243 #undef TYPED_ARRAY_CTOR
17244 default:
17245 UNREACHABLE();
17246 }
17247
17248 // 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
17249 Handle<Object> ctor;
17250 ASSIGN_RETURN_ON_EXCEPTION(
17251 isolate, ctor,
17252 Object::SpeciesConstructor(isolate, exemplar, default_ctor),
17253 JSTypedArray);
17254
17255 // 4. Return ? TypedArrayCreate(constructor, argumentList).
17256 return Create(isolate, Handle<JSFunction>::cast(ctor), argc, argv,
17257 method_name);
17258 }
17195 17259
17196 void JSGlobalObject::InvalidatePropertyCell(Handle<JSGlobalObject> global, 17260 void JSGlobalObject::InvalidatePropertyCell(Handle<JSGlobalObject> global,
17197 Handle<Name> name) { 17261 Handle<Name> name) {
17198 DCHECK(!global->HasFastProperties()); 17262 DCHECK(!global->HasFastProperties());
17199 auto dictionary = handle(global->global_dictionary()); 17263 auto dictionary = handle(global->global_dictionary());
17200 int entry = dictionary->FindEntry(name); 17264 int entry = dictionary->FindEntry(name);
17201 if (entry == GlobalDictionary::kNotFound) return; 17265 if (entry == GlobalDictionary::kNotFound) return;
17202 PropertyCell::InvalidateEntry(dictionary, entry); 17266 PropertyCell::InvalidateEntry(dictionary, entry);
17203 } 17267 }
17204 17268
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after
20513 // not 20577 // not
20514 // depend on this. 20578 // depend on this.
20515 return DICTIONARY_ELEMENTS; 20579 return DICTIONARY_ELEMENTS;
20516 } 20580 }
20517 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20581 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20518 return kind; 20582 return kind;
20519 } 20583 }
20520 } 20584 }
20521 } // namespace internal 20585 } // namespace internal
20522 } // namespace v8 20586 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698