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

Side by Side Diff: src/ia32/code-stubs-ia32.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/code-stubs.h ('k') | src/json.js » ('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 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 5677 matching lines...) Expand 10 before | Expand all | Expand 10 after
5688 if (!result_.is(eax)) { 5688 if (!result_.is(eax)) {
5689 __ mov(result_, eax); 5689 __ mov(result_, eax);
5690 } 5690 }
5691 call_helper.AfterCall(masm); 5691 call_helper.AfterCall(masm);
5692 __ jmp(&exit_); 5692 __ jmp(&exit_);
5693 5693
5694 __ Abort("Unexpected fallthrough from CharFromCode slow case"); 5694 __ Abort("Unexpected fallthrough from CharFromCode slow case");
5695 } 5695 }
5696 5696
5697 5697
5698 // -------------------------------------------------------------------------
5699 // StringCharAtGenerator
5700
5701 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) {
5702 char_code_at_generator_.GenerateFast(masm);
5703 char_from_code_generator_.GenerateFast(masm);
5704 }
5705
5706
5707 void StringCharAtGenerator::GenerateSlow(
5708 MacroAssembler* masm,
5709 const RuntimeCallHelper& call_helper) {
5710 char_code_at_generator_.GenerateSlow(masm, call_helper);
5711 char_from_code_generator_.GenerateSlow(masm, call_helper);
5712 }
5713
5714
5715 void StringAddStub::Generate(MacroAssembler* masm) { 5698 void StringAddStub::Generate(MacroAssembler* masm) {
5716 Label call_runtime, call_builtin; 5699 Label call_runtime, call_builtin;
5717 Builtins::JavaScript builtin_id = Builtins::ADD; 5700 Builtins::JavaScript builtin_id = Builtins::ADD;
5718 5701
5719 // Load the two arguments. 5702 // Load the two arguments.
5720 __ mov(eax, Operand(esp, 2 * kPointerSize)); // First argument. 5703 __ mov(eax, Operand(esp, 2 * kPointerSize)); // First argument.
5721 __ mov(edx, Operand(esp, 1 * kPointerSize)); // Second argument. 5704 __ mov(edx, Operand(esp, 1 * kPointerSize)); // Second argument.
5722 5705
5723 // Make sure that both arguments are strings if not known in advance. 5706 // Make sure that both arguments are strings if not known in advance.
5724 if (flags_ == NO_STRING_ADD_FLAGS) { 5707 if (flags_ == NO_STRING_ADD_FLAGS) {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
6371 // Shorter than original string's length: an actual substring. 6354 // Shorter than original string's length: an actual substring.
6372 __ j(below, &not_original_string, Label::kNear); 6355 __ j(below, &not_original_string, Label::kNear);
6373 // Longer than original string's length or negative: unsafe arguments. 6356 // Longer than original string's length or negative: unsafe arguments.
6374 __ j(above, &runtime); 6357 __ j(above, &runtime);
6375 // Return original string. 6358 // Return original string.
6376 Counters* counters = masm->isolate()->counters(); 6359 Counters* counters = masm->isolate()->counters();
6377 __ IncrementCounter(counters->sub_string_native(), 1); 6360 __ IncrementCounter(counters->sub_string_native(), 1);
6378 __ ret(3 * kPointerSize); 6361 __ ret(3 * kPointerSize);
6379 __ bind(&not_original_string); 6362 __ bind(&not_original_string);
6380 6363
6364 Label single_char;
6365 __ cmp(ecx, Immediate(Smi::FromInt(1)));
6366 __ j(equal, &single_char);
6367
6381 // eax: string 6368 // eax: string
6382 // ebx: instance type 6369 // ebx: instance type
6383 // ecx: sub string length (smi) 6370 // ecx: sub string length (smi)
6384 // edx: from index (smi) 6371 // edx: from index (smi)
6385 // Deal with different string types: update the index if necessary 6372 // Deal with different string types: update the index if necessary
6386 // and put the underlying string into edi. 6373 // and put the underlying string into edi.
6387 Label underlying_unpacked, sliced_string, seq_or_external_string; 6374 Label underlying_unpacked, sliced_string, seq_or_external_string;
6388 // If the string is not indirect, it can only be sequential or external. 6375 // If the string is not indirect, it can only be sequential or external.
6389 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); 6376 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag));
6390 STATIC_ASSERT(kIsIndirectStringMask != 0); 6377 STATIC_ASSERT(kIsIndirectStringMask != 0);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
6541 __ IncrementCounter(counters->sub_string_native(), 1); 6528 __ IncrementCounter(counters->sub_string_native(), 1);
6542 __ ret(3 * kPointerSize); 6529 __ ret(3 * kPointerSize);
6543 6530
6544 // Drop pushed values on the stack before tail call. 6531 // Drop pushed values on the stack before tail call.
6545 __ bind(&runtime_drop_two); 6532 __ bind(&runtime_drop_two);
6546 __ Drop(2); 6533 __ Drop(2);
6547 6534
6548 // Just jump to runtime to create the sub string. 6535 // Just jump to runtime to create the sub string.
6549 __ bind(&runtime); 6536 __ bind(&runtime);
6550 __ TailCallRuntime(Runtime::kSubString, 3, 1); 6537 __ TailCallRuntime(Runtime::kSubString, 3, 1);
6538
6539 __ bind(&single_char);
6540 // eax: string
6541 // ebx: instance type
6542 // ecx: sub string length (smi)
6543 // edx: from index (smi)
6544 StringCharAtGenerator generator(
6545 eax, edx, ecx, eax, &runtime, &runtime, &runtime, STRING_INDEX_IS_NUMBER);
6546 generator.GenerateFast(masm);
6547 __ ret(3 * kPointerSize);
6548 generator.SkipSlow(masm, &runtime);
6551 } 6549 }
6552 6550
6553 6551
6554 void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, 6552 void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
6555 Register left, 6553 Register left,
6556 Register right, 6554 Register right,
6557 Register scratch1, 6555 Register scratch1,
6558 Register scratch2) { 6556 Register scratch2) {
6559 Register length = scratch1; 6557 Register length = scratch1;
6560 6558
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
7698 // Restore ecx. 7696 // Restore ecx.
7699 __ pop(ecx); 7697 __ pop(ecx);
7700 __ ret(0); 7698 __ ret(0);
7701 } 7699 }
7702 7700
7703 #undef __ 7701 #undef __
7704 7702
7705 } } // namespace v8::internal 7703 } } // namespace v8::internal
7706 7704
7707 #endif // V8_TARGET_ARCH_IA32 7705 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698