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

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

Issue 1148007: Merge bleeding_edge from version 2.1.3 up to revision 4205... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
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
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 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 2702
2703 2703
2704 void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { 2704 void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) {
2705 #ifdef DEBUG 2705 #ifdef DEBUG
2706 int original_height = frame_->height(); 2706 int original_height = frame_->height();
2707 #endif 2707 #endif
2708 VirtualFrame::SpilledScope spilled_scope; 2708 VirtualFrame::SpilledScope spilled_scope;
2709 Comment cmnt(masm_, "[ ObjectLiteral"); 2709 Comment cmnt(masm_, "[ ObjectLiteral");
2710 2710
2711 // Load the function of this activation. 2711 // Load the function of this activation.
2712 __ ldr(r2, frame_->Function()); 2712 __ ldr(r3, frame_->Function());
2713 // Literal array. 2713 // Literal array.
2714 __ ldr(r2, FieldMemOperand(r2, JSFunction::kLiteralsOffset)); 2714 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
2715 // Literal index. 2715 // Literal index.
2716 __ mov(r1, Operand(Smi::FromInt(node->literal_index()))); 2716 __ mov(r2, Operand(Smi::FromInt(node->literal_index())));
2717 // Constant properties. 2717 // Constant properties.
2718 __ mov(r0, Operand(node->constant_properties())); 2718 __ mov(r1, Operand(node->constant_properties()));
2719 frame_->EmitPushMultiple(3, r2.bit() | r1.bit() | r0.bit()); 2719 // Should the object literal have fast elements?
2720 __ mov(r0, Operand(Smi::FromInt(node->fast_elements() ? 1 : 0)));
2721 frame_->EmitPushMultiple(4, r3.bit() | r2.bit() | r1.bit() | r0.bit());
2720 if (node->depth() > 1) { 2722 if (node->depth() > 1) {
2721 frame_->CallRuntime(Runtime::kCreateObjectLiteral, 3); 2723 frame_->CallRuntime(Runtime::kCreateObjectLiteral, 4);
2722 } else { 2724 } else {
2723 frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 3); 2725 frame_->CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
2724 } 2726 }
2725 frame_->EmitPush(r0); // save the result 2727 frame_->EmitPush(r0); // save the result
2726 for (int i = 0; i < node->properties()->length(); i++) { 2728 for (int i = 0; i < node->properties()->length(); i++) {
2727 // At the start of each iteration, the top of stack contains 2729 // At the start of each iteration, the top of stack contains
2728 // the newly created object literal. 2730 // the newly created object literal.
2729 ObjectLiteral::Property* property = node->properties()->at(i); 2731 ObjectLiteral::Property* property = node->properties()->at(i);
2730 Literal* key = property->key(); 2732 Literal* key = property->key();
2731 Expression* value = property->value(); 2733 Expression* value = property->value();
2732 switch (property->kind()) { 2734 switch (property->kind()) {
2733 case ObjectLiteral::Property::CONSTANT: 2735 case ObjectLiteral::Property::CONSTANT:
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 // in case no arguments adaptor frame is found below the current frame. 3592 // in case no arguments adaptor frame is found below the current frame.
3591 __ mov(r0, Operand(Smi::FromInt(scope()->num_parameters()))); 3593 __ mov(r0, Operand(Smi::FromInt(scope()->num_parameters())));
3592 3594
3593 // Call the shared stub to get to the arguments.length. 3595 // Call the shared stub to get to the arguments.length.
3594 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_LENGTH); 3596 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_LENGTH);
3595 frame_->CallStub(&stub, 0); 3597 frame_->CallStub(&stub, 0);
3596 frame_->EmitPush(r0); 3598 frame_->EmitPush(r0);
3597 } 3599 }
3598 3600
3599 3601
3600 void CodeGenerator::GenerateArgumentsAccess(ZoneList<Expression*>* args) { 3602 void CodeGenerator::GenerateArguments(ZoneList<Expression*>* args) {
3601 VirtualFrame::SpilledScope spilled_scope; 3603 VirtualFrame::SpilledScope spilled_scope;
3602 ASSERT(args->length() == 1); 3604 ASSERT(args->length() == 1);
3603 3605
3604 // Satisfy contract with ArgumentsAccessStub: 3606 // Satisfy contract with ArgumentsAccessStub:
3605 // Load the key into r1 and the formal parameters count into r0. 3607 // Load the key into r1 and the formal parameters count into r0.
3606 LoadAndSpill(args->at(0)); 3608 LoadAndSpill(args->at(0));
3607 frame_->EmitPop(r1); 3609 frame_->EmitPop(r1);
3608 __ mov(r0, Operand(Smi::FromInt(scope()->num_parameters()))); 3610 __ mov(r0, Operand(Smi::FromInt(scope()->num_parameters())));
3609 3611
3610 // Call the shared stub to get to arguments[key]. 3612 // Call the shared stub to get to arguments[key].
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3672 frame_->EmitPush(r0); 3674 frame_->EmitPush(r0);
3673 } 3675 }
3674 3676
3675 3677
3676 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { 3678 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) {
3677 ASSERT_EQ(args->length(), 1); 3679 ASSERT_EQ(args->length(), 1);
3678 3680
3679 // Load the argument on the stack and jump to the runtime. 3681 // Load the argument on the stack and jump to the runtime.
3680 Load(args->at(0)); 3682 Load(args->at(0));
3681 3683
3682 frame_->CallRuntime(Runtime::kNumberToString, 1); 3684 NumberToStringStub stub;
3685 frame_->CallStub(&stub, 1);
3683 frame_->EmitPush(r0); 3686 frame_->EmitPush(r0);
3684 } 3687 }
3685 3688
3686 3689
3687 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { 3690 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) {
3688 ASSERT_EQ(args->length(), 1); 3691 ASSERT_EQ(args->length(), 1);
3689 // Load the argument on the stack and jump to the runtime. 3692 // Load the argument on the stack and jump to the runtime.
3690 Load(args->at(0)); 3693 Load(args->at(0));
3691 frame_->CallRuntime(Runtime::kMath_sin, 1); 3694 frame_->CallRuntime(Runtime::kMath_sin, 1);
3692 frame_->EmitPush(r0); 3695 frame_->EmitPush(r0);
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
5271 __ tst(r3, Operand(kIsSymbolMask)); 5274 __ tst(r3, Operand(kIsSymbolMask));
5272 __ b(eq, slow); 5275 __ b(eq, slow);
5273 5276
5274 // Both are symbols. We already checked they weren't the same pointer 5277 // Both are symbols. We already checked they weren't the same pointer
5275 // so they are not equal. 5278 // so they are not equal.
5276 __ mov(r0, Operand(1)); // Non-zero indicates not equal. 5279 __ mov(r0, Operand(1)); // Non-zero indicates not equal.
5277 __ mov(pc, Operand(lr)); // Return. 5280 __ mov(pc, Operand(lr)); // Return.
5278 } 5281 }
5279 5282
5280 5283
5284 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
5285 Register object,
5286 Register result,
5287 Register scratch1,
5288 Register scratch2,
5289 bool object_is_smi,
5290 Label* not_found) {
5291 // Currently only lookup for smis. Check for smi if object is not known to be
5292 // a smi.
5293 if (!object_is_smi) {
5294 ASSERT(kSmiTag == 0);
5295 __ tst(object, Operand(kSmiTagMask));
5296 __ b(ne, not_found);
5297 }
5298
5299 // Use of registers. Register result is used as a temporary.
5300 Register number_string_cache = result;
5301 Register mask = scratch1;
5302 Register scratch = scratch2;
5303
5304 // Load the number string cache.
5305 __ LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex);
5306
5307 // Make the hash mask from the length of the number string cache. It
5308 // contains two elements (number and string) for each cache entry.
5309 __ ldr(mask, FieldMemOperand(number_string_cache, FixedArray::kLengthOffset));
5310 // Divide length by two (length is not a smi).
5311 __ mov(mask, Operand(mask, ASR, 1));
5312 __ sub(mask, mask, Operand(1)); // Make mask.
5313
5314 // Calculate the entry in the number string cache. The hash value in the
5315 // number string cache for smis is just the smi value.
5316 __ and_(scratch, mask, Operand(object, ASR, 1));
5317
5318 // Calculate address of entry in string cache: each entry consists
5319 // of two pointer sized fields.
5320 __ add(scratch,
5321 number_string_cache,
5322 Operand(scratch, LSL, kPointerSizeLog2 + 1));
5323
5324 // Check if the entry is the smi we are looking for.
5325 Register object1 = scratch1;
5326 __ ldr(object1, FieldMemOperand(scratch, FixedArray::kHeaderSize));
5327 __ cmp(object, object1);
5328 __ b(ne, not_found);
5329
5330 // Get the result from the cache.
5331 __ ldr(result,
5332 FieldMemOperand(scratch, FixedArray::kHeaderSize + kPointerSize));
5333
5334 __ IncrementCounter(&Counters::number_to_string_native,
5335 1,
5336 scratch1,
5337 scratch2);
5338 }
5339
5340
5341 void NumberToStringStub::Generate(MacroAssembler* masm) {
5342 Label runtime;
5343
5344 __ ldr(r1, MemOperand(sp, 0));
5345
5346 // Generate code to lookup number in the number string cache.
5347 GenerateLookupNumberStringCache(masm, r1, r0, r2, r3, false, &runtime);
5348 __ add(sp, sp, Operand(1 * kPointerSize));
5349 __ Ret();
5350
5351 __ bind(&runtime);
5352 // Handle number to string in the runtime system if not found in the cache.
5353 __ TailCallRuntime(Runtime::kNumberToString, 1, 1);
5354 }
5355
5356
5281 // On entry r0 (rhs) and r1 (lhs) are the values to be compared. 5357 // On entry r0 (rhs) and r1 (lhs) are the values to be compared.
5282 // On exit r0 is 0, positive or negative to indicate the result of 5358 // On exit r0 is 0, positive or negative to indicate the result of
5283 // the comparison. 5359 // the comparison.
5284 void CompareStub::Generate(MacroAssembler* masm) { 5360 void CompareStub::Generate(MacroAssembler* masm) {
5285 Label slow; // Call builtin. 5361 Label slow; // Call builtin.
5286 Label not_smis, both_loaded_as_doubles, lhs_not_nan; 5362 Label not_smis, both_loaded_as_doubles, lhs_not_nan;
5287 5363
5288 // NOTICE! This code is only reached after a smi-fast-case check, so 5364 // NOTICE! This code is only reached after a smi-fast-case check, so
5289 // it is certain that at least one operand isn't a smi. 5365 // it is certain that at least one operand isn't a smi.
5290 5366
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
5494 __ push(r1); 5570 __ push(r1);
5495 __ push(r0); 5571 __ push(r0);
5496 5572
5497 if (Token::ADD == operation) { 5573 if (Token::ADD == operation) {
5498 // Test for string arguments before calling runtime. 5574 // Test for string arguments before calling runtime.
5499 // r1 : first argument 5575 // r1 : first argument
5500 // r0 : second argument 5576 // r0 : second argument
5501 // sp[0] : second argument 5577 // sp[0] : second argument
5502 // sp[4] : first argument 5578 // sp[4] : first argument
5503 5579
5504 Label not_strings, not_string1, string1; 5580 Label not_strings, not_string1, string1, string1_smi2;
5505 __ tst(r1, Operand(kSmiTagMask)); 5581 __ tst(r1, Operand(kSmiTagMask));
5506 __ b(eq, &not_string1); 5582 __ b(eq, &not_string1);
5507 __ CompareObjectType(r1, r2, r2, FIRST_NONSTRING_TYPE); 5583 __ CompareObjectType(r1, r2, r2, FIRST_NONSTRING_TYPE);
5508 __ b(ge, &not_string1); 5584 __ b(ge, &not_string1);
5509 5585
5510 // First argument is a a string, test second. 5586 // First argument is a a string, test second.
5511 __ tst(r0, Operand(kSmiTagMask)); 5587 __ tst(r0, Operand(kSmiTagMask));
5512 __ b(eq, &string1); 5588 __ b(eq, &string1_smi2);
5513 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE); 5589 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE);
5514 __ b(ge, &string1); 5590 __ b(ge, &string1);
5515 5591
5516 // First and second argument are strings. 5592 // First and second argument are strings.
5517 StringAddStub stub(NO_STRING_CHECK_IN_STUB); 5593 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
5518 __ TailCallStub(&stub); 5594 __ TailCallStub(&string_add_stub);
5595
5596 __ bind(&string1_smi2);
5597 // First argument is a string, second is a smi. Try to lookup the number
5598 // string for the smi in the number string cache.
5599 NumberToStringStub::GenerateLookupNumberStringCache(
5600 masm, r0, r2, r4, r5, true, &string1);
5601
5602 // Replace second argument on stack and tailcall string add stub to make
5603 // the result.
5604 __ str(r2, MemOperand(sp, 0));
5605 __ TailCallStub(&string_add_stub);
5519 5606
5520 // Only first argument is a string. 5607 // Only first argument is a string.
5521 __ bind(&string1); 5608 __ bind(&string1);
5522 __ InvokeBuiltin(Builtins::STRING_ADD_LEFT, JUMP_JS); 5609 __ InvokeBuiltin(Builtins::STRING_ADD_LEFT, JUMP_JS);
5523 5610
5524 // First argument was not a string, test second. 5611 // First argument was not a string, test second.
5525 __ bind(&not_string1); 5612 __ bind(&not_string1);
5526 __ tst(r0, Operand(kSmiTagMask)); 5613 __ tst(r0, Operand(kSmiTagMask));
5527 __ b(eq, &not_strings); 5614 __ b(eq, &not_strings);
5528 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE); 5615 __ CompareObjectType(r0, r2, r2, FIRST_NONSTRING_TYPE);
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after
7955 8042
7956 // Just jump to runtime to add the two strings. 8043 // Just jump to runtime to add the two strings.
7957 __ bind(&string_add_runtime); 8044 __ bind(&string_add_runtime);
7958 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 8045 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
7959 } 8046 }
7960 8047
7961 8048
7962 #undef __ 8049 #undef __
7963 8050
7964 } } // namespace v8::internal 8051 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.h ('k') | src/arm/constants-arm.h » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698