From: svenpanne@chromium.org Date: Fri, 1 Jul 2011 07:50:46 +0000 (+0000) Subject: Simplify UnaryOpStub a little bit. X-Git-Tag: upstream/4.7.83~19004 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6ec7808db156a39108438c2024da7618d6ec969;p=platform%2Fupstream%2Fv8.git Simplify UnaryOpStub a little bit. Only a single constructor is really needed. Make UnaryOp_Patch's arguments simpler, avoiding encoding/decoding things in a cryptic way. Review URL: http://codereview.chromium.org/7248063 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8503 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 137e4e8fa..3c9733234 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1731,22 +1731,14 @@ void UnaryOpStub::Generate(MacroAssembler* masm) { void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { - // Prepare to push argument. - __ mov(r3, Operand(r0)); - - // Push this stub's key. Although the operation and the type info are - // encoded into the key, the encoding is opaque, so push them too. - __ mov(r2, Operand(Smi::FromInt(MinorKey()))); - __ mov(r1, Operand(Smi::FromInt(op_))); + __ mov(r3, Operand(r0)); // the operand + __ mov(r2, Operand(Smi::FromInt(op_))); + __ mov(r1, Operand(Smi::FromInt(mode_))); __ mov(r0, Operand(Smi::FromInt(operand_type_))); - __ Push(r3, r2, r1, r0); __ TailCallExternalReference( - ExternalReference(IC_Utility(IC::kUnaryOp_Patch), - masm->isolate()), - 4, - 1); + ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1); } diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index 8e3e9dc00..742735130 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -60,18 +60,11 @@ class TranscendentalCacheStub: public CodeStub { class UnaryOpStub: public CodeStub { public: - UnaryOpStub(Token::Value op, UnaryOverwriteMode mode) + UnaryOpStub(Token::Value op, + UnaryOverwriteMode mode, + UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) : op_(op), mode_(mode), - operand_type_(UnaryOpIC::UNINITIALIZED), - name_(NULL) { - } - - UnaryOpStub( - int key, - UnaryOpIC::TypeInfo operand_type) - : op_(OpBits::decode(key)), - mode_(ModeBits::decode(key)), operand_type_(operand_type), name_(NULL) { } @@ -89,8 +82,7 @@ class UnaryOpStub: public CodeStub { #ifdef DEBUG void Print() { - PrintF("UnaryOpStub %d (op %s), " - "(mode %d, runtime_type_info %s)\n", + PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n", MinorKey(), Token::String(op_), static_cast(mode_), diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index d97206d0b..8624ed96b 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -554,12 +554,10 @@ void UnaryOpStub::Generate(MacroAssembler* masm) { void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { __ pop(ecx); // Save return address. - __ push(eax); - // the argument is now on top. - // Push this stub's key. Although the operation and the type info are - // encoded into the key, the encoding is opaque, so push them too. - __ push(Immediate(Smi::FromInt(MinorKey()))); + + __ push(eax); // the operand __ push(Immediate(Smi::FromInt(op_))); + __ push(Immediate(Smi::FromInt(mode_))); __ push(Immediate(Smi::FromInt(operand_type_))); __ push(ecx); // Push return address. @@ -567,8 +565,7 @@ void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { // Patch the caller to an appropriate specialized stub and return the // operation result to the caller of the stub. __ TailCallExternalReference( - ExternalReference(IC_Utility(IC::kUnaryOp_Patch), - masm->isolate()), 4, 1); + ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1); } diff --git a/src/ia32/code-stubs-ia32.h b/src/ia32/code-stubs-ia32.h index d51549d54..d02aa01d7 100644 --- a/src/ia32/code-stubs-ia32.h +++ b/src/ia32/code-stubs-ia32.h @@ -62,16 +62,11 @@ class TranscendentalCacheStub: public CodeStub { class UnaryOpStub: public CodeStub { public: - UnaryOpStub(Token::Value op, UnaryOverwriteMode mode) + UnaryOpStub(Token::Value op, + UnaryOverwriteMode mode, + UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) : op_(op), mode_(mode), - operand_type_(UnaryOpIC::UNINITIALIZED), - name_(NULL) { - } - - UnaryOpStub(int key, UnaryOpIC::TypeInfo operand_type) - : op_(OpBits::decode(key)), - mode_(ModeBits::decode(key)), operand_type_(operand_type), name_(NULL) { } @@ -89,8 +84,7 @@ class UnaryOpStub: public CodeStub { #ifdef DEBUG void Print() { - PrintF("TypeRecordingUnaryOpStub %d (op %s), " - "(mode %d, runtime_type_info %s)\n", + PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n", MinorKey(), Token::String(op_), static_cast(mode_), diff --git a/src/ic.cc b/src/ic.cc index fd8c27045..77d750d4f 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -2332,15 +2332,15 @@ RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { HandleScope scope(isolate); Handle operand = args.at(0); - int key = args.smi_at(1); - Token::Value op = static_cast(args.smi_at(2)); + Token::Value op = static_cast(args.smi_at(1)); + UnaryOverwriteMode mode = static_cast(args.smi_at(2)); UnaryOpIC::TypeInfo previous_type = static_cast(args.smi_at(3)); UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand); type = UnaryOpIC::ComputeNewType(type, previous_type); - UnaryOpStub stub(key, type); + UnaryOpStub stub(op, mode, type); Handle code = stub.GetCode(); if (!code.is_null()) { if (FLAG_trace_ic) { diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 234a7dd40..d7fac867f 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -1846,19 +1846,13 @@ void UnaryOpStub::Generate(MacroAssembler* masm) { void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { // Argument is in a0 and v0 at this point, so we can overwrite a0. - // Push this stub's key. Although the operation and the type info are - // encoded into the key, the encoding is opaque, so push them too. - __ li(a2, Operand(Smi::FromInt(MinorKey()))); - __ li(a1, Operand(Smi::FromInt(op_))); + __ li(a2, Operand(Smi::FromInt(op_))); + __ li(a1, Operand(Smi::FromInt(mode_))); __ li(a0, Operand(Smi::FromInt(operand_type_))); - __ Push(v0, a2, a1, a0); __ TailCallExternalReference( - ExternalReference(IC_Utility(IC::kUnaryOp_Patch), - masm->isolate()), - 4, - 1); + ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1); } diff --git a/src/mips/code-stubs-mips.h b/src/mips/code-stubs-mips.h index e2323c174..6c70bdd70 100644 --- a/src/mips/code-stubs-mips.h +++ b/src/mips/code-stubs-mips.h @@ -61,18 +61,11 @@ class TranscendentalCacheStub: public CodeStub { class UnaryOpStub: public CodeStub { public: - UnaryOpStub(Token::Value op, UnaryOverwriteMode mode) + UnaryOpStub(Token::Value op, + UnaryOverwriteMode mode, + UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) : op_(op), mode_(mode), - operand_type_(UnaryOpIC::UNINITIALIZED), - name_(NULL) { - } - - UnaryOpStub( - int key, - UnaryOpIC::TypeInfo operand_type) - : op_(OpBits::decode(key)), - mode_(ModeBits::decode(key)), operand_type_(operand_type), name_(NULL) { } @@ -90,8 +83,7 @@ class UnaryOpStub: public CodeStub { #ifdef DEBUG void Print() { - PrintF("UnaryOpStub %d (op %s), " - "(mode %d, runtime_type_info %s)\n", + PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n", MinorKey(), Token::String(op_), static_cast(mode_), diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 81514d1e9..6c1a9c643 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -424,12 +424,10 @@ void UnaryOpStub::Generate(MacroAssembler* masm) { void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { __ pop(rcx); // Save return address. - __ push(rax); - // Left and right arguments are now on top. - // Push this stub's key. Although the operation and the type info are - // encoded into the key, the encoding is opaque, so push them too. - __ Push(Smi::FromInt(MinorKey())); + + __ push(rax); // the operand __ Push(Smi::FromInt(op_)); + __ Push(Smi::FromInt(mode_)); __ Push(Smi::FromInt(operand_type_)); __ push(rcx); // Push return address. @@ -437,10 +435,7 @@ void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { // Patch the caller to an appropriate specialized stub and return the // operation result to the caller of the stub. __ TailCallExternalReference( - ExternalReference(IC_Utility(IC::kUnaryOp_Patch), - masm->isolate()), - 4, - 1); + ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1); } diff --git a/src/x64/code-stubs-x64.h b/src/x64/code-stubs-x64.h index a7ed91c50..6a07b3b84 100644 --- a/src/x64/code-stubs-x64.h +++ b/src/x64/code-stubs-x64.h @@ -61,18 +61,11 @@ class TranscendentalCacheStub: public CodeStub { class UnaryOpStub: public CodeStub { public: - UnaryOpStub(Token::Value op, UnaryOverwriteMode mode) + UnaryOpStub(Token::Value op, + UnaryOverwriteMode mode, + UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED) : op_(op), mode_(mode), - operand_type_(UnaryOpIC::UNINITIALIZED), - name_(NULL) { - } - - UnaryOpStub( - int key, - UnaryOpIC::TypeInfo operand_type) - : op_(OpBits::decode(key)), - mode_(ModeBits::decode(key)), operand_type_(operand_type), name_(NULL) { } @@ -90,8 +83,7 @@ class UnaryOpStub: public CodeStub { #ifdef DEBUG void Print() { - PrintF("UnaryOpStub %d (op %s), " - "(mode %d, runtime_type_info %s)\n", + PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n", MinorKey(), Token::String(op_), static_cast(mode_),