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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 12217071: Combine %_SubString and %_StringCharAt. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/string.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4740 matching lines...) Expand 10 before | Expand all | Expand 10 after
4751 if (!result_.is(rax)) { 4751 if (!result_.is(rax)) {
4752 __ movq(result_, rax); 4752 __ movq(result_, rax);
4753 } 4753 }
4754 call_helper.AfterCall(masm); 4754 call_helper.AfterCall(masm);
4755 __ jmp(&exit_); 4755 __ jmp(&exit_);
4756 4756
4757 __ Abort("Unexpected fallthrough from CharFromCode slow case"); 4757 __ Abort("Unexpected fallthrough from CharFromCode slow case");
4758 } 4758 }
4759 4759
4760 4760
4761 // -------------------------------------------------------------------------
4762 // StringCharAtGenerator
4763
4764 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) {
4765 char_code_at_generator_.GenerateFast(masm);
4766 char_from_code_generator_.GenerateFast(masm);
4767 }
4768
4769
4770 void StringCharAtGenerator::GenerateSlow(
4771 MacroAssembler* masm,
4772 const RuntimeCallHelper& call_helper) {
4773 char_code_at_generator_.GenerateSlow(masm, call_helper);
4774 char_from_code_generator_.GenerateSlow(masm, call_helper);
4775 }
4776
4777
4778 void StringAddStub::Generate(MacroAssembler* masm) { 4761 void StringAddStub::Generate(MacroAssembler* masm) {
4779 Label call_runtime, call_builtin; 4762 Label call_runtime, call_builtin;
4780 Builtins::JavaScript builtin_id = Builtins::ADD; 4763 Builtins::JavaScript builtin_id = Builtins::ADD;
4781 4764
4782 // Load the two arguments. 4765 // Load the two arguments.
4783 __ movq(rax, Operand(rsp, 2 * kPointerSize)); // First argument (left). 4766 __ movq(rax, Operand(rsp, 2 * kPointerSize)); // First argument (left).
4784 __ movq(rdx, Operand(rsp, 1 * kPointerSize)); // Second argument (right). 4767 __ movq(rdx, Operand(rsp, 1 * kPointerSize)); // Second argument (right).
4785 4768
4786 // Make sure that both arguments are strings if not known in advance. 4769 // Make sure that both arguments are strings if not known in advance.
4787 if (flags_ == NO_STRING_ADD_FLAGS) { 4770 if (flags_ == NO_STRING_ADD_FLAGS) {
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 Label not_original_string; 5371 Label not_original_string;
5389 // Shorter than original string's length: an actual substring. 5372 // Shorter than original string's length: an actual substring.
5390 __ j(below, &not_original_string, Label::kNear); 5373 __ j(below, &not_original_string, Label::kNear);
5391 // Longer than original string's length or negative: unsafe arguments. 5374 // Longer than original string's length or negative: unsafe arguments.
5392 __ j(above, &runtime); 5375 __ j(above, &runtime);
5393 // Return original string. 5376 // Return original string.
5394 Counters* counters = masm->isolate()->counters(); 5377 Counters* counters = masm->isolate()->counters();
5395 __ IncrementCounter(counters->sub_string_native(), 1); 5378 __ IncrementCounter(counters->sub_string_native(), 1);
5396 __ ret(kArgumentsSize); 5379 __ ret(kArgumentsSize);
5397 __ bind(&not_original_string); 5380 __ bind(&not_original_string);
5381
5382 Label single_char;
5383 __ SmiCompare(rcx, Smi::FromInt(1));
5384 __ j(equal, &single_char);
5385
5398 __ SmiToInteger32(rcx, rcx); 5386 __ SmiToInteger32(rcx, rcx);
5399 5387
5400 // rax: string 5388 // rax: string
5401 // rbx: instance type 5389 // rbx: instance type
5402 // rcx: sub string length 5390 // rcx: sub string length
5403 // rdx: from index (smi) 5391 // rdx: from index (smi)
5404 // Deal with different string types: update the index if necessary 5392 // Deal with different string types: update the index if necessary
5405 // and put the underlying string into edi. 5393 // and put the underlying string into edi.
5406 Label underlying_unpacked, sliced_string, seq_or_external_string; 5394 Label underlying_unpacked, sliced_string, seq_or_external_string;
5407 // If the string is not indirect, it can only be sequential or external. 5395 // If the string is not indirect, it can only be sequential or external.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
5548 // rsi: character of sub string start 5536 // rsi: character of sub string start
5549 // r14: original value of rsi 5537 // r14: original value of rsi
5550 StringHelper::GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false); 5538 StringHelper::GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false);
5551 __ movq(rsi, r14); // Restore esi. 5539 __ movq(rsi, r14); // Restore esi.
5552 __ IncrementCounter(counters->sub_string_native(), 1); 5540 __ IncrementCounter(counters->sub_string_native(), 1);
5553 __ ret(kArgumentsSize); 5541 __ ret(kArgumentsSize);
5554 5542
5555 // Just jump to runtime to create the sub string. 5543 // Just jump to runtime to create the sub string.
5556 __ bind(&runtime); 5544 __ bind(&runtime);
5557 __ TailCallRuntime(Runtime::kSubString, 3, 1); 5545 __ TailCallRuntime(Runtime::kSubString, 3, 1);
5546
5547 __ bind(&single_char);
5548 // rax: string
5549 // rbx: instance type
5550 // rcx: sub string length (smi)
5551 // rdx: from index (smi)
5552 StringCharAtGenerator generator(
5553 rax, rdx, rcx, rax, &runtime, &runtime, &runtime, STRING_INDEX_IS_NUMBER);
5554 generator.GenerateFast(masm);
5555 __ ret(kArgumentsSize);
5556 generator.SkipSlow(masm, &runtime);
5558 } 5557 }
5559 5558
5560 5559
5561 void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, 5560 void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
5562 Register left, 5561 Register left,
5563 Register right, 5562 Register right,
5564 Register scratch1, 5563 Register scratch1,
5565 Register scratch2) { 5564 Register scratch2) {
5566 Register length = scratch1; 5565 Register length = scratch1;
5567 5566
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
6712 #endif 6711 #endif
6713 6712
6714 __ Ret(); 6713 __ Ret();
6715 } 6714 }
6716 6715
6717 #undef __ 6716 #undef __
6718 6717
6719 } } // namespace v8::internal 6718 } } // namespace v8::internal
6720 6719
6721 #endif // V8_TARGET_ARCH_X64 6720 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/string.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698