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

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

Issue 2541843006: [stubs] Add LoadFixedArrayElements with int index (Closed)
Patch Set: Address comments 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/builtins/builtins-regexp.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/regexp/regexp-utils.h" 9 #include "src/regexp/regexp-utils.h"
10 10
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 typedef compiler::Node Node; 1274 typedef compiler::Node Node;
1275 CodeStubAssembler assembler(state); 1275 CodeStubAssembler assembler(state);
1276 1276
1277 Node* receiver = assembler.Parameter(0); 1277 Node* receiver = assembler.Parameter(0);
1278 Node* context = assembler.Parameter(3); 1278 Node* context = assembler.Parameter(3);
1279 1279
1280 Node* string = assembler.ToThisString(context, receiver, 1280 Node* string = assembler.ToThisString(context, receiver,
1281 "String.prototype[Symbol.iterator]"); 1281 "String.prototype[Symbol.iterator]");
1282 1282
1283 Node* native_context = assembler.LoadNativeContext(context); 1283 Node* native_context = assembler.LoadNativeContext(context);
1284 Node* map = assembler.LoadFixedArrayElement( 1284 Node* map = assembler.LoadContextElement(native_context,
1285 native_context, 1285 Context::STRING_ITERATOR_MAP_INDEX);
1286 assembler.IntPtrConstant(Context::STRING_ITERATOR_MAP_INDEX), 0,
1287 CodeStubAssembler::INTPTR_PARAMETERS);
1288 Node* iterator = assembler.Allocate(JSStringIterator::kSize); 1286 Node* iterator = assembler.Allocate(JSStringIterator::kSize);
1289 assembler.StoreMapNoWriteBarrier(iterator, map); 1287 assembler.StoreMapNoWriteBarrier(iterator, map);
1290 assembler.StoreObjectFieldRoot(iterator, JSValue::kPropertiesOffset, 1288 assembler.StoreObjectFieldRoot(iterator, JSValue::kPropertiesOffset,
1291 Heap::kEmptyFixedArrayRootIndex); 1289 Heap::kEmptyFixedArrayRootIndex);
1292 assembler.StoreObjectFieldRoot(iterator, JSObject::kElementsOffset, 1290 assembler.StoreObjectFieldRoot(iterator, JSObject::kElementsOffset,
1293 Heap::kEmptyFixedArrayRootIndex); 1291 Heap::kEmptyFixedArrayRootIndex);
1294 assembler.StoreObjectFieldNoWriteBarrier( 1292 assembler.StoreObjectFieldNoWriteBarrier(
1295 iterator, JSStringIterator::kStringOffset, string); 1293 iterator, JSStringIterator::kStringOffset, string);
1296 Node* index = assembler.SmiConstant(Smi::kZero); 1294 Node* index = assembler.SmiConstant(Smi::kZero);
1297 assembler.StoreObjectFieldNoWriteBarrier( 1295 assembler.StoreObjectFieldNoWriteBarrier(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 assembler.StoreObjectFieldNoWriteBarrier( 1431 assembler.StoreObjectFieldNoWriteBarrier(
1434 iterator, JSStringIterator::kNextIndexOffset, 1432 iterator, JSStringIterator::kNextIndexOffset,
1435 assembler.SmiAdd(position, length)); 1433 assembler.SmiAdd(position, length));
1436 var_done.Bind(assembler.BooleanConstant(false)); 1434 var_done.Bind(assembler.BooleanConstant(false));
1437 assembler.Goto(&return_result); 1435 assembler.Goto(&return_result);
1438 } 1436 }
1439 1437
1440 assembler.Bind(&return_result); 1438 assembler.Bind(&return_result);
1441 { 1439 {
1442 Node* native_context = assembler.LoadNativeContext(context); 1440 Node* native_context = assembler.LoadNativeContext(context);
1443 Node* map = assembler.LoadFixedArrayElement( 1441 Node* map = assembler.LoadContextElement(
1444 native_context, 1442 native_context, Context::ITERATOR_RESULT_MAP_INDEX);
1445 assembler.IntPtrConstant(Context::ITERATOR_RESULT_MAP_INDEX), 0,
1446 CodeStubAssembler::INTPTR_PARAMETERS);
1447 Node* result = assembler.Allocate(JSIteratorResult::kSize); 1443 Node* result = assembler.Allocate(JSIteratorResult::kSize);
1448 assembler.StoreMapNoWriteBarrier(result, map); 1444 assembler.StoreMapNoWriteBarrier(result, map);
1449 assembler.StoreObjectFieldRoot(result, JSIteratorResult::kPropertiesOffset, 1445 assembler.StoreObjectFieldRoot(result, JSIteratorResult::kPropertiesOffset,
1450 Heap::kEmptyFixedArrayRootIndex); 1446 Heap::kEmptyFixedArrayRootIndex);
1451 assembler.StoreObjectFieldRoot(result, JSIteratorResult::kElementsOffset, 1447 assembler.StoreObjectFieldRoot(result, JSIteratorResult::kElementsOffset,
1452 Heap::kEmptyFixedArrayRootIndex); 1448 Heap::kEmptyFixedArrayRootIndex);
1453 assembler.StoreObjectFieldNoWriteBarrier( 1449 assembler.StoreObjectFieldNoWriteBarrier(
1454 result, JSIteratorResult::kValueOffset, var_value.value()); 1450 result, JSIteratorResult::kValueOffset, var_value.value());
1455 assembler.StoreObjectFieldNoWriteBarrier( 1451 assembler.StoreObjectFieldNoWriteBarrier(
1456 result, JSIteratorResult::kDoneOffset, var_done.value()); 1452 result, JSIteratorResult::kDoneOffset, var_done.value());
1457 assembler.Return(result); 1453 assembler.Return(result);
1458 } 1454 }
1459 1455
1460 assembler.Bind(&throw_bad_receiver); 1456 assembler.Bind(&throw_bad_receiver);
1461 { 1457 {
1462 // The {receiver} is not a valid JSGeneratorObject. 1458 // The {receiver} is not a valid JSGeneratorObject.
1463 Node* result = assembler.CallRuntime( 1459 Node* result = assembler.CallRuntime(
1464 Runtime::kThrowIncompatibleMethodReceiver, context, 1460 Runtime::kThrowIncompatibleMethodReceiver, context,
1465 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( 1461 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked(
1466 "String Iterator.prototype.next", TENURED)), 1462 "String Iterator.prototype.next", TENURED)),
1467 iterator); 1463 iterator);
1468 assembler.Return(result); // Never reached. 1464 assembler.Return(result); // Never reached.
1469 } 1465 }
1470 } 1466 }
1471 1467
1472 } // namespace internal 1468 } // namespace internal
1473 } // namespace v8 1469 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-regexp.cc ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698