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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 546087: Implement inline string compare on ARM. (Closed)
Patch Set: Further optimization of ARM version Created 10 years, 11 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
« no previous file with comments | « src/list.h ('k') | src/x64/macro-assembler-x64.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 8213 matching lines...) Expand 10 before | Expand all | Expand 10 after
8224 __ j(not_equal, &loop); 8224 __ j(not_equal, &loop);
8225 } 8225 }
8226 // Completed loop without finding different characters. 8226 // Completed loop without finding different characters.
8227 // Compare lengths (precomputed). 8227 // Compare lengths (precomputed).
8228 __ bind(&compare_lengths); 8228 __ bind(&compare_lengths);
8229 __ testl(length_difference, length_difference); 8229 __ testl(length_difference, length_difference);
8230 __ j(not_zero, &result_not_equal); 8230 __ j(not_zero, &result_not_equal);
8231 8231
8232 // Result is EQUAL. 8232 // Result is EQUAL.
8233 __ Move(rax, Smi::FromInt(EQUAL)); 8233 __ Move(rax, Smi::FromInt(EQUAL));
8234 __ IncrementCounter(&Counters::string_compare_native, 1);
8235 __ ret(2 * kPointerSize); 8234 __ ret(2 * kPointerSize);
8236 8235
8237 Label result_greater; 8236 Label result_greater;
8238 __ bind(&result_not_equal); 8237 __ bind(&result_not_equal);
8239 // Unequal comparison of left to right, either character or length. 8238 // Unequal comparison of left to right, either character or length.
8240 __ j(greater, &result_greater); 8239 __ j(greater, &result_greater);
8241 8240
8242 // Result is LESS. 8241 // Result is LESS.
8243 __ Move(rax, Smi::FromInt(LESS)); 8242 __ Move(rax, Smi::FromInt(LESS));
8244 __ IncrementCounter(&Counters::string_compare_native, 1);
8245 __ ret(2 * kPointerSize); 8243 __ ret(2 * kPointerSize);
8246 8244
8247 // Result is GREATER. 8245 // Result is GREATER.
8248 __ bind(&result_greater); 8246 __ bind(&result_greater);
8249 __ Move(rax, Smi::FromInt(GREATER)); 8247 __ Move(rax, Smi::FromInt(GREATER));
8250 __ IncrementCounter(&Counters::string_compare_native, 1);
8251 __ ret(2 * kPointerSize); 8248 __ ret(2 * kPointerSize);
8252 } 8249 }
8253 8250
8254 8251
8255 void StringCompareStub::Generate(MacroAssembler* masm) { 8252 void StringCompareStub::Generate(MacroAssembler* masm) {
8256 Label runtime; 8253 Label runtime;
8257 8254
8258 // Stack frame on entry. 8255 // Stack frame on entry.
8259 // rsp[0]: return address 8256 // rsp[0]: return address
8260 // rsp[8]: right string 8257 // rsp[8]: right string
8261 // rsp[16]: left string 8258 // rsp[16]: left string
8262 8259
8263 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); // left 8260 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); // left
8264 __ movq(rax, Operand(rsp, 1 * kPointerSize)); // right 8261 __ movq(rax, Operand(rsp, 1 * kPointerSize)); // right
8265 8262
8266 // Check for identity. 8263 // Check for identity.
8267 Label not_same; 8264 Label not_same;
8268 __ cmpq(rdx, rax); 8265 __ cmpq(rdx, rax);
8269 __ j(not_equal, &not_same); 8266 __ j(not_equal, &not_same);
8270 __ Move(rax, Smi::FromInt(EQUAL)); 8267 __ Move(rax, Smi::FromInt(EQUAL));
8271 __ IncrementCounter(&Counters::string_compare_native, 1); 8268 __ IncrementCounter(&Counters::string_compare_native, 1);
8272 __ ret(2 * kPointerSize); 8269 __ ret(2 * kPointerSize);
8273 8270
8274 __ bind(&not_same); 8271 __ bind(&not_same);
8275 8272
8276 // Check that both are sequential ASCII strings. 8273 // Check that both are sequential ASCII strings.
8277 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime); 8274 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime);
8278 8275
8279 // Inline comparison of ascii strings. 8276 // Inline comparison of ascii strings.
8277 __ IncrementCounter(&Counters::string_compare_native, 1);
8280 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); 8278 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8);
8281 8279
8282 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 8280 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
8283 // tagged as a small integer. 8281 // tagged as a small integer.
8284 __ bind(&runtime); 8282 __ bind(&runtime);
8285 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); 8283 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1);
8286 } 8284 }
8287 8285
8288 #undef __ 8286 #undef __
8289 8287
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
8375 // Call the function from C++. 8373 // Call the function from C++.
8376 return FUNCTION_CAST<ModuloFunction>(buffer); 8374 return FUNCTION_CAST<ModuloFunction>(buffer);
8377 } 8375 }
8378 8376
8379 #endif 8377 #endif
8380 8378
8381 8379
8382 #undef __ 8380 #undef __
8383 8381
8384 } } // namespace v8::internal 8382 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/list.h ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698