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

Side by Side Diff: src/builtins/builtins-array.cc

Issue 2484003002: [builtins] implement JSBuiltinReducer for ArrayIteratorNext() (Closed)
Patch Set: fix tests when ignition is used Created 4 years, 1 month 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/bootstrapper.cc ('k') | src/code-stub-assembler.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins.h" 5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h" 6 #include "src/builtins/builtins-utils.h"
7 7
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/contexts.h" 9 #include "src/contexts.h"
10 #include "src/elements.h" 10 #include "src/elements.h"
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 &allocate_iterator_result); 2294 &allocate_iterator_result);
2295 2295
2296 Node* array_type = assembler->LoadInstanceType(array); 2296 Node* array_type = assembler->LoadInstanceType(array);
2297 assembler->Branch( 2297 assembler->Branch(
2298 assembler->Word32Equal(array_type, 2298 assembler->Word32Equal(array_type,
2299 assembler->Int32Constant(JS_TYPED_ARRAY_TYPE)), 2299 assembler->Int32Constant(JS_TYPED_ARRAY_TYPE)),
2300 &if_istypedarray, &if_isgeneric); 2300 &if_istypedarray, &if_isgeneric);
2301 2301
2302 assembler->Bind(&if_isgeneric); 2302 assembler->Bind(&if_isgeneric);
2303 { 2303 {
2304 Label if_wasfastarray(assembler);
2305
2304 Node* length = nullptr; 2306 Node* length = nullptr;
2305 { 2307 {
2306 Variable var_length(assembler, MachineRepresentation::kTagged); 2308 Variable var_length(assembler, MachineRepresentation::kTagged);
2307 Label if_isarray(assembler), if_isnotarray(assembler), done(assembler); 2309 Label if_isarray(assembler), if_isnotarray(assembler), done(assembler);
2308 assembler->Branch( 2310 assembler->Branch(
2309 assembler->Word32Equal(array_type, 2311 assembler->Word32Equal(array_type,
2310 assembler->Int32Constant(JS_ARRAY_TYPE)), 2312 assembler->Int32Constant(JS_ARRAY_TYPE)),
2311 &if_isarray, &if_isnotarray); 2313 &if_isarray, &if_isnotarray);
2312 2314
2313 assembler->Bind(&if_isarray); 2315 assembler->Bind(&if_isarray);
2314 { 2316 {
2315 var_length.Bind( 2317 var_length.Bind(
2316 assembler->LoadObjectField(array, JSArray::kLengthOffset)); 2318 assembler->LoadObjectField(array, JSArray::kLengthOffset));
2317 assembler->Goto(&done); 2319
2320 // Invalidate protector cell if needed
2321 assembler->Branch(
2322 assembler->WordNotEqual(orig_map, assembler->UndefinedConstant()),
2323 &if_wasfastarray, &done);
2324
2325 assembler->Bind(&if_wasfastarray);
2326 {
2327 Label if_invalid(assembler, Label::kDeferred);
2328 // A fast array iterator transitioned to a slow iterator during
2329 // iteration. Invalidate fast_array_iteration_prtoector cell to
2330 // prevent potential deopt loops.
2331 assembler->StoreObjectFieldNoWriteBarrier(
2332 iterator, JSArrayIterator::kIteratedObjectMapOffset,
2333 assembler->UndefinedConstant());
2334 assembler->GotoIf(
2335 assembler->Uint32LessThanOrEqual(
2336 instance_type, assembler->Int32Constant(
2337 JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE)),
2338 &done);
2339
2340 Node* invalid = assembler->SmiConstant(
2341 Smi::FromInt(Isolate::kArrayProtectorInvalid));
2342 Node* cell = assembler->LoadRoot(
2343 Heap::kFastArrayIterationProtectorRootIndex);
2344 assembler->StoreObjectFieldNoWriteBarrier(cell, Cell::kValueOffset,
2345 invalid);
2346 assembler->Goto(&done);
2347 }
2318 } 2348 }
2319 2349
2320 assembler->Bind(&if_isnotarray); 2350 assembler->Bind(&if_isnotarray);
2321 { 2351 {
2322 Node* length_string = assembler->HeapConstant( 2352 Node* length_string = assembler->HeapConstant(
2323 assembler->isolate()->factory()->length_string()); 2353 assembler->isolate()->factory()->length_string());
2324 Callable get_property = 2354 Callable get_property =
2325 CodeFactory::GetProperty(assembler->isolate()); 2355 CodeFactory::GetProperty(assembler->isolate());
2326 Node* length = 2356 Node* length =
2327 assembler->CallStub(get_property, context, array, length_string); 2357 assembler->CallStub(get_property, context, array, length_string);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 2400
2371 assembler->Bind(&if_isnotdetached); 2401 assembler->Bind(&if_isnotdetached);
2372 { 2402 {
2373 var_length.Bind( 2403 var_length.Bind(
2374 assembler->LoadObjectField(array, JSTypedArray::kLengthOffset)); 2404 assembler->LoadObjectField(array, JSTypedArray::kLengthOffset));
2375 assembler->Goto(&done); 2405 assembler->Goto(&done);
2376 } 2406 }
2377 2407
2378 assembler->Bind(&if_isdetached); 2408 assembler->Bind(&if_isdetached);
2379 { 2409 {
2410 // TODO(caitp): If IsDetached(buffer) is true, throw a TypeError, per
2411 // https://github.com/tc39/ecma262/issues/713
2380 var_length.Bind(assembler->SmiConstant(Smi::kZero)); 2412 var_length.Bind(assembler->SmiConstant(Smi::kZero));
2381 assembler->Goto(&done); 2413 assembler->Goto(&done);
2382 } 2414 }
2383 2415
2384 assembler->Bind(&done); 2416 assembler->Bind(&done);
2385 length = var_length.value(); 2417 length = var_length.value();
2386 } 2418 }
2387 CSA_ASSERT(assembler, assembler->TaggedIsSmi(length)); 2419 CSA_ASSERT(assembler, assembler->TaggedIsSmi(length));
2388 CSA_ASSERT(assembler, assembler->TaggedIsSmi(index)); 2420 CSA_ASSERT(assembler, assembler->TaggedIsSmi(index));
2389 2421
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 Runtime::kThrowIncompatibleMethodReceiver, context, 2615 Runtime::kThrowIncompatibleMethodReceiver, context,
2584 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( 2616 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked(
2585 "Array Iterator.prototype.next", TENURED)), 2617 "Array Iterator.prototype.next", TENURED)),
2586 iterator); 2618 iterator);
2587 assembler->Return(result); 2619 assembler->Return(result);
2588 } 2620 }
2589 } 2621 }
2590 2622
2591 } // namespace internal 2623 } // namespace internal
2592 } // namespace v8 2624 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698