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

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

Issue 668254: Port of string plus smi optimization from ia32 to x64 and ARM. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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/arm/codegen-arm.h ('k') | src/x64/codegen-x64.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 frame_->EmitPush(r0); 3662 frame_->EmitPush(r0);
3663 } 3663 }
3664 3664
3665 3665
3666 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { 3666 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) {
3667 ASSERT_EQ(args->length(), 1); 3667 ASSERT_EQ(args->length(), 1);
3668 3668
3669 // Load the argument on the stack and jump to the runtime. 3669 // Load the argument on the stack and jump to the runtime.
3670 Load(args->at(0)); 3670 Load(args->at(0));
3671 3671
3672 frame_->CallRuntime(Runtime::kNumberToString, 1); 3672 NumberToStringStub stub;
3673 frame_->CallStub(&stub, 1);
3673 frame_->EmitPush(r0); 3674 frame_->EmitPush(r0);
3674 } 3675 }
3675 3676
3676 3677
3677 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { 3678 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) {
3678 ASSERT_EQ(args->length(), 1); 3679 ASSERT_EQ(args->length(), 1);
3679 // Load the argument on the stack and jump to the runtime. 3680 // Load the argument on the stack and jump to the runtime.
3680 Load(args->at(0)); 3681 Load(args->at(0));
3681 frame_->CallRuntime(Runtime::kMath_sin, 1); 3682 frame_->CallRuntime(Runtime::kMath_sin, 1);
3682 frame_->EmitPush(r0); 3683 frame_->EmitPush(r0);
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
5261 __ tst(r3, Operand(kIsSymbolMask)); 5262 __ tst(r3, Operand(kIsSymbolMask));
5262 __ b(eq, slow); 5263 __ b(eq, slow);
5263 5264
5264 // Both are symbols. We already checked they weren't the same pointer 5265 // Both are symbols. We already checked they weren't the same pointer
5265 // so they are not equal. 5266 // so they are not equal.
5266 __ mov(r0, Operand(1)); // Non-zero indicates not equal. 5267 __ mov(r0, Operand(1)); // Non-zero indicates not equal.
5267 __ mov(pc, Operand(lr)); // Return. 5268 __ mov(pc, Operand(lr)); // Return.
5268 } 5269 }
5269 5270
5270 5271
5272 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
5273 Register object,
5274 Register result,
5275 Register scratch1,
5276 Register scratch2,
5277 bool object_is_smi,
5278 Label* not_found) {
5279 // Currently only lookup for smis. Check for smi if object is not known to be
5280 // a smi.
5281 if (!object_is_smi) {
5282 ASSERT(kSmiTag == 0);
5283 __ tst(object, Operand(kSmiTagMask));
5284 __ b(ne, not_found);
5285 }
5286
5287 // Use of registers. Register result is used as a temporary.
5288 Register number_string_cache = result;
5289 Register mask = scratch1;
5290 Register scratch = scratch2;
5291
5292 // Load the number string cache.
5293 __ LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex);
5294
5295 // Make the hash mask from the length of the number string cache. It
5296 // contains two elements (number and string) for each cache entry.
5297 __ ldr(mask, FieldMemOperand(number_string_cache, FixedArray::kLengthOffset));
5298 // Divide length by two (length is not a smi).
5299 __ mov(mask, Operand(mask, ASR, 1));
5300 __ sub(mask, mask, Operand(1)); // Make mask.
5301
5302 // Calculate the entry in the number string cache. The hash value in the
5303 // number string cache for smis is just the smi value.
5304 __ and_(scratch, mask, Operand(object, ASR, 1));
5305
5306 // Calculate address of entry in string cache: each entry consists
5307 // of two pointer sized fields.
5308 __ add(scratch,
5309 number_string_cache,
5310 Operand(scratch, LSL, kPointerSizeLog2 + 1));
5311
5312 // Check if the entry is the smi we are looking for.
5313 Register object1 = scratch1;
5314 __ ldr(object1, FieldMemOperand(scratch, FixedArray::kHeaderSize));
5315 __ cmp(object, object1);
5316 __ b(ne, not_found);
5317
5318 // Get the result from the cache.
5319 __ ldr(result,
5320 FieldMemOperand(scratch, FixedArray::kHeaderSize + kPointerSize));
5321
5322 __ IncrementCounter(&Counters::number_to_string_native,
5323 1,
5324 scratch1,
5325 scratch2);
5326 }
5327
5328
5329 void NumberToStringStub::Generate(MacroAssembler* masm) {
5330 Label runtime;
5331
5332 __ ldr(r1, MemOperand(sp, 0));
5333
5334 // Generate code to lookup number in the number string cache.
5335 GenerateLookupNumberStringCache(masm, r1, r0, r2, r3, false, &runtime);
5336 __ add(sp, sp, Operand(1 * kPointerSize));
5337 __ Ret();
5338
5339 __ bind(&runtime);
5340 // Handle number to string in the runtime system if not found in the cache.
5341 __ TailCallRuntime(Runtime::kNumberToString, 1, 1);
5342 }
5343
5344
5271 // On entry r0 (rhs) and r1 (lhs) are the values to be compared. 5345 // On entry r0 (rhs) and r1 (lhs) are the values to be compared.
5272 // On exit r0 is 0, positive or negative to indicate the result of 5346 // On exit r0 is 0, positive or negative to indicate the result of
5273 // the comparison. 5347 // the comparison.
5274 void CompareStub::Generate(MacroAssembler* masm) { 5348 void CompareStub::Generate(MacroAssembler* masm) {
5275 Label slow; // Call builtin. 5349 Label slow; // Call builtin.
5276 Label not_smis, both_loaded_as_doubles, lhs_not_nan; 5350 Label not_smis, both_loaded_as_doubles, lhs_not_nan;
5277 5351
5278 // NOTICE! This code is only reached after a smi-fast-case check, so 5352 // NOTICE! This code is only reached after a smi-fast-case check, so
5279 // it is certain that at least one operand isn't a smi. 5353 // it is certain that at least one operand isn't a smi.
5280 5354
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
5484 __ push(r1); 5558 __ push(r1);
5485 __ push(r0); 5559 __ push(r0);
5486 5560
5487 if (Token::ADD == operation) { 5561 if (Token::ADD == operation) {
5488 // Test for string arguments before calling runtime. 5562 // Test for string arguments before calling runtime.
5489 // r1 : first argument 5563 // r1 : first argument
5490 // r0 : second argument 5564 // r0 : second argument
5491 // sp[0] : second argument 5565 // sp[0] : second argument
5492 // sp[4] : first argument 5566 // sp[4] : first argument
5493 5567
5494 Label not_strings, not_string1, string1; 5568 Label not_strings, not_string1, string1, string1_smi2;
5495 __ tst(r1, Operand(kSmiTagMask)); 5569 __ tst(r1, Operand(kSmiTagMask));
5496 __ b(eq, &not_string1); 5570 __ b(eq, &not_string1);
5497 __ CompareObjectType(r1, r2, r2, FIRST_NONSTRING_TYPE); 5571 __ CompareObjectType(r1, r2, r2, FIRST_NONSTRING_TYPE);
5498 __ b(ge, &not_string1); 5572 __ b(ge, &not_string1);
5499 5573
5500 // First argument is a a string, test second. 5574 // First argument is a a string, test second.
5501 __ tst(r0, Operand(kSmiTagMask)); 5575 __ tst(r0, Operand(kSmiTagMask));
5502 __ b(eq, &string1); 5576 __ b(eq, &string1_smi2);
5503 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE); 5577 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE);
5504 __ b(ge, &string1); 5578 __ b(ge, &string1);
5505 5579
5506 // First and second argument are strings. 5580 // First and second argument are strings.
5507 StringAddStub stub(NO_STRING_CHECK_IN_STUB); 5581 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
5508 __ TailCallStub(&stub); 5582 __ TailCallStub(&string_add_stub);
5583
5584 __ bind(&string1_smi2);
5585 // First argument is a string, second is a smi. Try to lookup the number
5586 // string for the smi in the number string cache.
5587 NumberToStringStub::GenerateLookupNumberStringCache(
5588 masm, r0, r2, r4, r5, true, &string1);
5589
5590 // Replace second argument on stack and tailcall string add stub to make
5591 // the result.
5592 __ str(r2, MemOperand(sp, 0));
5593 __ TailCallStub(&string_add_stub);
5509 5594
5510 // Only first argument is a string. 5595 // Only first argument is a string.
5511 __ bind(&string1); 5596 __ bind(&string1);
5512 __ InvokeBuiltin(Builtins::STRING_ADD_LEFT, JUMP_JS); 5597 __ InvokeBuiltin(Builtins::STRING_ADD_LEFT, JUMP_JS);
5513 5598
5514 // First argument was not a string, test second. 5599 // First argument was not a string, test second.
5515 __ bind(&not_string1); 5600 __ bind(&not_string1);
5516 __ tst(r0, Operand(kSmiTagMask)); 5601 __ tst(r0, Operand(kSmiTagMask));
5517 __ b(eq, &not_strings); 5602 __ b(eq, &not_strings);
5518 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE); 5603 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE);
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
7707 7792
7708 // Just jump to runtime to add the two strings. 7793 // Just jump to runtime to add the two strings.
7709 __ bind(&string_add_runtime); 7794 __ bind(&string_add_runtime);
7710 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 7795 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
7711 } 7796 }
7712 7797
7713 7798
7714 #undef __ 7799 #undef __
7715 7800
7716 } } // namespace v8::internal 7801 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.h ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698