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

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

Issue 2573573004: [stubs] Enable graph verification for builtins. (Closed)
Patch Set: 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
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-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 #include "src/regexp/regexp-utils.h" 9 #include "src/regexp/regexp-utils.h"
10 10
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // ES6 section 21.1 String Objects 427 // ES6 section 21.1 String Objects
428 428
429 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) 429 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits )
430 void Builtins::Generate_StringFromCharCode( 430 void Builtins::Generate_StringFromCharCode(
431 compiler::CodeAssemblerState* state) { 431 compiler::CodeAssemblerState* state) {
432 typedef CodeStubAssembler::Label Label; 432 typedef CodeStubAssembler::Label Label;
433 typedef compiler::Node Node; 433 typedef compiler::Node Node;
434 typedef CodeStubAssembler::Variable Variable; 434 typedef CodeStubAssembler::Variable Variable;
435 CodeStubAssembler assembler(state); 435 CodeStubAssembler assembler(state);
436 436
437 Node* argc = assembler.ChangeInt32ToIntPtr( 437 Node* argc = assembler.Parameter(BuiltinDescriptor::kArgumentsCount);
438 assembler.Parameter(BuiltinDescriptor::kArgumentsCount));
439 Node* context = assembler.Parameter(BuiltinDescriptor::kContext); 438 Node* context = assembler.Parameter(BuiltinDescriptor::kContext);
440 439
441 CodeStubArguments arguments(&assembler, argc); 440 CodeStubArguments arguments(&assembler, argc);
441 // From now on use word-size argc value.
442 argc = arguments.GetLength();
442 443
443 // Check if we have exactly one argument (plus the implicit receiver), i.e. 444 // Check if we have exactly one argument (plus the implicit receiver), i.e.
444 // if the parent frame is not an arguments adaptor frame. 445 // if the parent frame is not an arguments adaptor frame.
445 Label if_oneargument(&assembler), if_notoneargument(&assembler); 446 Label if_oneargument(&assembler), if_notoneargument(&assembler);
446 assembler.Branch(assembler.WordEqual(argc, assembler.IntPtrConstant(1)), 447 assembler.Branch(assembler.WordEqual(argc, assembler.IntPtrConstant(1)),
447 &if_oneargument, &if_notoneargument); 448 &if_oneargument, &if_notoneargument);
448 449
449 assembler.Bind(&if_oneargument); 450 assembler.Bind(&if_oneargument);
450 { 451 {
451 // Single argument case, perform fast single character string cache lookup 452 // Single argument case, perform fast single character string cache lookup
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 compiler::Node* LoadSurrogatePairInternal(CodeStubAssembler* assembler, 1306 compiler::Node* LoadSurrogatePairInternal(CodeStubAssembler* assembler,
1306 compiler::Node* string, 1307 compiler::Node* string,
1307 compiler::Node* length, 1308 compiler::Node* length,
1308 compiler::Node* index, 1309 compiler::Node* index,
1309 UnicodeEncoding encoding) { 1310 UnicodeEncoding encoding) {
1310 typedef CodeStubAssembler::Label Label; 1311 typedef CodeStubAssembler::Label Label;
1311 typedef compiler::Node Node; 1312 typedef compiler::Node Node;
1312 typedef CodeStubAssembler::Variable Variable; 1313 typedef CodeStubAssembler::Variable Variable;
1313 Label handle_surrogate_pair(assembler), return_result(assembler); 1314 Label handle_surrogate_pair(assembler), return_result(assembler);
1314 Variable var_result(assembler, MachineRepresentation::kWord32); 1315 Variable var_result(assembler, MachineRepresentation::kWord32);
1315 Variable var_trail(assembler, MachineRepresentation::kWord16); 1316 Variable var_trail(assembler, MachineRepresentation::kWord32);
1316 var_result.Bind(assembler->StringCharCodeAt(string, index)); 1317 var_result.Bind(assembler->StringCharCodeAt(string, index));
1317 var_trail.Bind(assembler->Int32Constant(0)); 1318 var_trail.Bind(assembler->Int32Constant(0));
1318 1319
1319 assembler->GotoIf(assembler->Word32NotEqual( 1320 assembler->GotoIf(assembler->Word32NotEqual(
1320 assembler->Word32And(var_result.value(), 1321 assembler->Word32And(var_result.value(),
1321 assembler->Int32Constant(0xFC00)), 1322 assembler->Int32Constant(0xFC00)),
1322 assembler->Int32Constant(0xD800)), 1323 assembler->Int32Constant(0xD800)),
1323 &return_result); 1324 &return_result);
1324 Node* next_index = 1325 Node* next_index =
1325 assembler->SmiAdd(index, assembler->SmiConstant(Smi::FromInt(1))); 1326 assembler->SmiAdd(index, assembler->SmiConstant(Smi::FromInt(1)));
(...skipping 17 matching lines...) Expand all
1343 lead, assembler->Int32Constant(0xD800))); 1344 lead, assembler->Int32Constant(0xD800)));
1344 CSA_SLOW_ASSERT(assembler, assembler->Uint32LessThan( 1345 CSA_SLOW_ASSERT(assembler, assembler->Uint32LessThan(
1345 lead, assembler->Int32Constant(0xDC00))); 1346 lead, assembler->Int32Constant(0xDC00)));
1346 CSA_SLOW_ASSERT(assembler, assembler->Uint32GreaterThanOrEqual( 1347 CSA_SLOW_ASSERT(assembler, assembler->Uint32GreaterThanOrEqual(
1347 trail, assembler->Int32Constant(0xDC00))); 1348 trail, assembler->Int32Constant(0xDC00)));
1348 CSA_SLOW_ASSERT(assembler, assembler->Uint32LessThan( 1349 CSA_SLOW_ASSERT(assembler, assembler->Uint32LessThan(
1349 trail, assembler->Int32Constant(0xE000))); 1350 trail, assembler->Int32Constant(0xE000)));
1350 1351
1351 switch (encoding) { 1352 switch (encoding) {
1352 case UnicodeEncoding::UTF16: 1353 case UnicodeEncoding::UTF16:
1353 var_result.Bind(assembler->WordOr( 1354 var_result.Bind(assembler->Word32Or(
1354 // Need to swap the order for big-endian platforms 1355 // Need to swap the order for big-endian platforms
1355 #if V8_TARGET_BIG_ENDIAN 1356 #if V8_TARGET_BIG_ENDIAN
1356 assembler->WordShl(lead, assembler->Int32Constant(16)), trail)); 1357 assembler->Word32Shl(lead, assembler->Int32Constant(16)), trail));
1357 #else 1358 #else
1358 assembler->WordShl(trail, assembler->Int32Constant(16)), lead)); 1359 assembler->Word32Shl(trail, assembler->Int32Constant(16)), lead));
1359 #endif 1360 #endif
1360 break; 1361 break;
1361 1362
1362 case UnicodeEncoding::UTF32: { 1363 case UnicodeEncoding::UTF32: {
1363 // Convert UTF16 surrogate pair into |word32| code point, encoded as 1364 // Convert UTF16 surrogate pair into |word32| code point, encoded as
1364 // UTF32. 1365 // UTF32.
1365 Node* surrogate_offset = 1366 Node* surrogate_offset =
1366 assembler->Int32Constant(0x10000 - (0xD800 << 10) - 0xDC00); 1367 assembler->Int32Constant(0x10000 - (0xD800 << 10) - 0xDC00);
1367 1368
1368 // (lead << 10) + trail + SURROGATE_OFFSET 1369 // (lead << 10) + trail + SURROGATE_OFFSET
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 var_done.Bind(assembler.BooleanConstant(true)); 1404 var_done.Bind(assembler.BooleanConstant(true));
1404 1405
1405 Label throw_bad_receiver(&assembler), next_codepoint(&assembler), 1406 Label throw_bad_receiver(&assembler), next_codepoint(&assembler),
1406 return_result(&assembler); 1407 return_result(&assembler);
1407 1408
1408 Node* iterator = assembler.Parameter(0); 1409 Node* iterator = assembler.Parameter(0);
1409 Node* context = assembler.Parameter(3); 1410 Node* context = assembler.Parameter(3);
1410 1411
1411 assembler.GotoIf(assembler.TaggedIsSmi(iterator), &throw_bad_receiver); 1412 assembler.GotoIf(assembler.TaggedIsSmi(iterator), &throw_bad_receiver);
1412 assembler.GotoUnless( 1413 assembler.GotoUnless(
1413 assembler.WordEqual(assembler.LoadInstanceType(iterator), 1414 assembler.Word32Equal(assembler.LoadInstanceType(iterator),
1414 assembler.Int32Constant(JS_STRING_ITERATOR_TYPE)), 1415 assembler.Int32Constant(JS_STRING_ITERATOR_TYPE)),
1415 &throw_bad_receiver); 1416 &throw_bad_receiver);
1416 1417
1417 Node* string = 1418 Node* string =
1418 assembler.LoadObjectField(iterator, JSStringIterator::kStringOffset); 1419 assembler.LoadObjectField(iterator, JSStringIterator::kStringOffset);
1419 Node* position = 1420 Node* position =
1420 assembler.LoadObjectField(iterator, JSStringIterator::kNextIndexOffset); 1421 assembler.LoadObjectField(iterator, JSStringIterator::kNextIndexOffset);
1421 Node* length = assembler.LoadObjectField(string, String::kLengthOffset); 1422 Node* length = assembler.LoadObjectField(string, String::kLengthOffset);
1422 1423
1423 assembler.Branch(assembler.SmiLessThan(position, length), &next_codepoint, 1424 assembler.Branch(assembler.SmiLessThan(position, length), &next_codepoint,
1424 &return_result); 1425 &return_result);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 Runtime::kThrowIncompatibleMethodReceiver, context, 1462 Runtime::kThrowIncompatibleMethodReceiver, context,
1462 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( 1463 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked(
1463 "String Iterator.prototype.next", TENURED)), 1464 "String Iterator.prototype.next", TENURED)),
1464 iterator); 1465 iterator);
1465 assembler.Return(result); // Never reached. 1466 assembler.Return(result); // Never reached.
1466 } 1467 }
1467 } 1468 }
1468 1469
1469 } // namespace internal 1470 } // namespace internal
1470 } // namespace v8 1471 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698