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

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

Issue 2850043: Specialize GenericUnaryStub so that it knows whether it needs to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 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 | « no previous file | src/arm/full-codegen-arm.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 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 5405 matching lines...) Expand 10 before | Expand all | Expand 10 after
5416 } 5416 }
5417 5417
5418 } else if (op == Token::TYPEOF) { 5418 } else if (op == Token::TYPEOF) {
5419 // Special case for loading the typeof expression; see comment on 5419 // Special case for loading the typeof expression; see comment on
5420 // LoadTypeofExpression(). 5420 // LoadTypeofExpression().
5421 LoadTypeofExpression(node->expression()); 5421 LoadTypeofExpression(node->expression());
5422 frame_->CallRuntime(Runtime::kTypeof, 1); 5422 frame_->CallRuntime(Runtime::kTypeof, 1);
5423 frame_->EmitPush(r0); // r0 has result 5423 frame_->EmitPush(r0); // r0 has result
5424 5424
5425 } else { 5425 } else {
5426 bool overwrite = 5426 bool can_overwrite =
5427 (node->expression()->AsBinaryOperation() != NULL && 5427 (node->expression()->AsBinaryOperation() != NULL &&
5428 node->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); 5428 node->expression()->AsBinaryOperation()->ResultOverwriteAllowed());
5429 UnaryOverwriteMode overwrite =
5430 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE;
5431
5432 bool no_negative_zero = node->expression()->no_negative_zero();
5429 Load(node->expression()); 5433 Load(node->expression());
5430 switch (op) { 5434 switch (op) {
5431 case Token::NOT: 5435 case Token::NOT:
5432 case Token::DELETE: 5436 case Token::DELETE:
5433 case Token::TYPEOF: 5437 case Token::TYPEOF:
5434 UNREACHABLE(); // handled above 5438 UNREACHABLE(); // handled above
5435 break; 5439 break;
5436 5440
5437 case Token::SUB: { 5441 case Token::SUB: {
5438 frame_->PopToR0(); 5442 frame_->PopToR0();
5439 GenericUnaryOpStub stub(Token::SUB, overwrite); 5443 GenericUnaryOpStub stub(
5444 Token::SUB,
5445 overwrite,
5446 no_negative_zero ? kIgnoreNegativeZero : kStrictNegativeZero);
5440 frame_->CallStub(&stub, 0); 5447 frame_->CallStub(&stub, 0);
5441 frame_->EmitPush(r0); // r0 has result 5448 frame_->EmitPush(r0); // r0 has result
5442 break; 5449 break;
5443 } 5450 }
5444 5451
5445 case Token::BIT_NOT: { 5452 case Token::BIT_NOT: {
5446 Register tos = frame_->PopToRegister(); 5453 Register tos = frame_->PopToRegister();
5447 JumpTarget not_smi_label; 5454 JumpTarget not_smi_label;
5448 JumpTarget continue_label; 5455 JumpTarget continue_label;
5449 // Smi check. 5456 // Smi check.
(...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after
8892 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); 8899 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
8893 8900
8894 if (op_ == Token::SUB) { 8901 if (op_ == Token::SUB) {
8895 // Check whether the value is a smi. 8902 // Check whether the value is a smi.
8896 Label try_float; 8903 Label try_float;
8897 __ tst(r0, Operand(kSmiTagMask)); 8904 __ tst(r0, Operand(kSmiTagMask));
8898 __ b(ne, &try_float); 8905 __ b(ne, &try_float);
8899 8906
8900 // Go slow case if the value of the expression is zero 8907 // Go slow case if the value of the expression is zero
8901 // to make sure that we switch between 0 and -0. 8908 // to make sure that we switch between 0 and -0.
8902 __ cmp(r0, Operand(0)); 8909 if (negative_zero_ == kStrictNegativeZero) {
8903 __ b(eq, &slow); 8910 // If we have to check for zero, then we can check for the max negative
8904 8911 // smi while we are at it.
8905 // The value of the expression is a smi that is not zero. Try 8912 __ bic(ip, r0, Operand(0x80000000), SetCC);
8906 // optimistic subtraction '0 - value'. 8913 __ b(eq, &slow);
8907 __ rsb(r1, r0, Operand(0), SetCC); 8914 __ rsb(r0, r0, Operand(0));
8908 __ b(vs, &slow); 8915 __ StubReturn(1);
8909 8916 } else {
8910 __ mov(r0, Operand(r1)); // Set r0 to result. 8917 // The value of the expression is a smi and 0 is OK for -0. Try
8911 __ b(&done); 8918 // optimistic subtraction '0 - value'.
8919 __ rsb(r0, r0, Operand(0), SetCC);
8920 __ StubReturn(1, vc);
8921 // We don't have to reverse the optimistic neg since the only case
8922 // where we fall through is the minimum negative Smi, which is the case
8923 // where the neg leaves the register unchanged.
8924 __ jmp(&slow); // Go slow on max negative Smi.
8925 }
8912 8926
8913 __ bind(&try_float); 8927 __ bind(&try_float);
8914 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); 8928 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset));
8915 __ AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); 8929 __ AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
8916 __ cmp(r1, heap_number_map); 8930 __ cmp(r1, heap_number_map);
8917 __ b(ne, &slow); 8931 __ b(ne, &slow);
8918 // r0 is a heap number. Get a new heap number in r1. 8932 // r0 is a heap number. Get a new heap number in r1.
8919 if (overwrite_) { 8933 if (overwrite_ == UNARY_OVERWRITE) {
8920 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); 8934 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset));
8921 __ eor(r2, r2, Operand(HeapNumber::kSignMask)); // Flip sign. 8935 __ eor(r2, r2, Operand(HeapNumber::kSignMask)); // Flip sign.
8922 __ str(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); 8936 __ str(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset));
8923 } else { 8937 } else {
8924 __ AllocateHeapNumber(r1, r2, r3, r6, &slow); 8938 __ AllocateHeapNumber(r1, r2, r3, r6, &slow);
8925 __ ldr(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); 8939 __ ldr(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset));
8926 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); 8940 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset));
8927 __ str(r3, FieldMemOperand(r1, HeapNumber::kMantissaOffset)); 8941 __ str(r3, FieldMemOperand(r1, HeapNumber::kMantissaOffset));
8928 __ eor(r2, r2, Operand(HeapNumber::kSignMask)); // Flip sign. 8942 __ eor(r2, r2, Operand(HeapNumber::kSignMask)); // Flip sign.
8929 __ str(r2, FieldMemOperand(r1, HeapNumber::kExponentOffset)); 8943 __ str(r2, FieldMemOperand(r1, HeapNumber::kExponentOffset));
(...skipping 12 matching lines...) Expand all
8942 // Do the bitwise operation (move negated) and check if the result 8956 // Do the bitwise operation (move negated) and check if the result
8943 // fits in a smi. 8957 // fits in a smi.
8944 Label try_float; 8958 Label try_float;
8945 __ mvn(r1, Operand(r1)); 8959 __ mvn(r1, Operand(r1));
8946 __ add(r2, r1, Operand(0x40000000), SetCC); 8960 __ add(r2, r1, Operand(0x40000000), SetCC);
8947 __ b(mi, &try_float); 8961 __ b(mi, &try_float);
8948 __ mov(r0, Operand(r1, LSL, kSmiTagSize)); 8962 __ mov(r0, Operand(r1, LSL, kSmiTagSize));
8949 __ b(&done); 8963 __ b(&done);
8950 8964
8951 __ bind(&try_float); 8965 __ bind(&try_float);
8952 if (!overwrite_) { 8966 if (!overwrite_ == UNARY_OVERWRITE) {
8953 // Allocate a fresh heap number, but don't overwrite r0 until 8967 // Allocate a fresh heap number, but don't overwrite r0 until
8954 // we're sure we can do it without going through the slow case 8968 // we're sure we can do it without going through the slow case
8955 // that needs the value in r0. 8969 // that needs the value in r0.
8956 __ AllocateHeapNumber(r2, r3, r4, r6, &slow); 8970 __ AllocateHeapNumber(r2, r3, r4, r6, &slow);
8957 __ mov(r0, Operand(r2)); 8971 __ mov(r0, Operand(r2));
8958 } 8972 }
8959 8973
8960 if (CpuFeatures::IsSupported(VFP3)) { 8974 if (CpuFeatures::IsSupported(VFP3)) {
8961 // Convert the int32 in r1 to the heap number in r0. r2 is corrupted. 8975 // Convert the int32 in r1 to the heap number in r0. r2 is corrupted.
8962 CpuFeatures::Scope scope(VFP3); 8976 CpuFeatures::Scope scope(VFP3);
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
11199 __ bind(&string_add_runtime); 11213 __ bind(&string_add_runtime);
11200 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 11214 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
11201 } 11215 }
11202 11216
11203 11217
11204 #undef __ 11218 #undef __
11205 11219
11206 } } // namespace v8::internal 11220 } } // namespace v8::internal
11207 11221
11208 #endif // V8_TARGET_ARCH_ARM 11222 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698