Re-submitting binary op ICs for ARM. Does not break debug tests

now.

Review URL: http://codereview.chromium.org/1629008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4365 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c9b3e45c
This diff is collapsed.
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#ifndef V8_ARM_CODEGEN_ARM_H_ #ifndef V8_ARM_CODEGEN_ARM_H_
#define V8_ARM_CODEGEN_ARM_H_ #define V8_ARM_CODEGEN_ARM_H_
#include "ic-inl.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -475,6 +477,15 @@ class GenericBinaryOpStub : public CodeStub { ...@@ -475,6 +477,15 @@ class GenericBinaryOpStub : public CodeStub {
mode_(mode), mode_(mode),
constant_rhs_(constant_rhs), constant_rhs_(constant_rhs),
specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)), specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)),
runtime_operands_type_(BinaryOpIC::DEFAULT),
name_(NULL) { }
GenericBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info)
: op_(OpBits::decode(key)),
mode_(ModeBits::decode(key)),
constant_rhs_(KnownBitsForMinorKey(KnownIntBits::decode(key))),
specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op_, constant_rhs_)),
runtime_operands_type_(type_info),
name_(NULL) { } name_(NULL) { }
private: private:
...@@ -482,25 +493,32 @@ class GenericBinaryOpStub : public CodeStub { ...@@ -482,25 +493,32 @@ class GenericBinaryOpStub : public CodeStub {
OverwriteMode mode_; OverwriteMode mode_;
int constant_rhs_; int constant_rhs_;
bool specialized_on_rhs_; bool specialized_on_rhs_;
BinaryOpIC::TypeInfo runtime_operands_type_;
char* name_; char* name_;
static const int kMaxKnownRhs = 0x40000000; static const int kMaxKnownRhs = 0x40000000;
// Minor key encoding in 16 bits. // Minor key encoding in 18 bits.
class ModeBits: public BitField<OverwriteMode, 0, 2> {}; class ModeBits: public BitField<OverwriteMode, 0, 2> {};
class OpBits: public BitField<Token::Value, 2, 6> {}; class OpBits: public BitField<Token::Value, 2, 6> {};
class KnownIntBits: public BitField<int, 8, 8> {}; class KnownIntBits: public BitField<int, 8, 8> {};
class TypeInfoBits: public BitField<int, 16, 2> {};
Major MajorKey() { return GenericBinaryOp; } Major MajorKey() { return GenericBinaryOp; }
int MinorKey() { int MinorKey() {
// Encode the parameters in a unique 16 bit value. // Encode the parameters in a unique 18 bit value.
return OpBits::encode(op_) return OpBits::encode(op_)
| ModeBits::encode(mode_) | ModeBits::encode(mode_)
| KnownIntBits::encode(MinorKeyForKnownInt()); | KnownIntBits::encode(MinorKeyForKnownInt())
| TypeInfoBits::encode(runtime_operands_type_);
} }
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
void HandleNonSmiBitwiseOp(MacroAssembler* masm); void HandleNonSmiBitwiseOp(MacroAssembler* masm);
void HandleBinaryOpSlowCases(MacroAssembler* masm,
Label* not_smi,
const Builtins::JavaScript& builtin);
void GenerateTypeTransition(MacroAssembler* masm);
static bool RhsIsOneWeWantToOptimizeFor(Token::Value op, int constant_rhs) { static bool RhsIsOneWeWantToOptimizeFor(Token::Value op, int constant_rhs) {
if (constant_rhs == CodeGenerator::kUnknownIntValue) return false; if (constant_rhs == CodeGenerator::kUnknownIntValue) return false;
...@@ -527,6 +545,33 @@ class GenericBinaryOpStub : public CodeStub { ...@@ -527,6 +545,33 @@ class GenericBinaryOpStub : public CodeStub {
return key; return key;
} }
int KnownBitsForMinorKey(int key) {
if (!key) return 0;
if (key <= 11) return key - 1;
int d = 1;
while (key != 12) {
key--;
d <<= 1;
}
return d;
}
bool ShouldGenerateSmiCode() {
return ((op_ != Token::DIV && op_ != Token::MOD) || specialized_on_rhs_) &&
runtime_operands_type_ != BinaryOpIC::HEAP_NUMBERS &&
runtime_operands_type_ != BinaryOpIC::STRINGS;
}
bool ShouldGenerateFPCode() {
return runtime_operands_type_ != BinaryOpIC::STRINGS;
}
virtual int GetCodeKind() { return Code::BINARY_OP_IC; }
virtual InlineCacheState GetICState() {
return BinaryOpIC::ToState(runtime_operands_type_);
}
const char* GetName(); const char* GetName();
#ifdef DEBUG #ifdef DEBUG
......
...@@ -1433,8 +1433,9 @@ BinaryOpIC::State BinaryOpIC::ToState(TypeInfo type_info) { ...@@ -1433,8 +1433,9 @@ BinaryOpIC::State BinaryOpIC::ToState(TypeInfo type_info) {
BinaryOpIC::TypeInfo BinaryOpIC::GetTypeInfo(Object* left, BinaryOpIC::TypeInfo BinaryOpIC::GetTypeInfo(Object* left,
Object* right) { Object* right) {
// Patching is never requested for the two smis. if (left->IsSmi() && right->IsSmi()) {
ASSERT(!left->IsSmi() || !right->IsSmi()); return GENERIC;
}
if (left->IsNumber() && right->IsNumber()) { if (left->IsNumber() && right->IsNumber()) {
return HEAP_NUMBERS; return HEAP_NUMBERS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment