summaryrefslogtreecommitdiffstats
path: root/src/code-stubs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/code-stubs.h')
-rw-r--r--src/code-stubs.h133
1 files changed, 118 insertions, 15 deletions
diff --git a/src/code-stubs.h b/src/code-stubs.h
index b156647d..b7804b77 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -29,7 +29,6 @@
#define V8_CODE_STUBS_H_
#include "globals.h"
-#include "macro-assembler.h"
namespace v8 {
namespace internal {
@@ -39,11 +38,16 @@ namespace internal {
#define CODE_STUB_LIST_ALL_PLATFORMS(V) \
V(CallFunction) \
V(GenericBinaryOp) \
+ V(TypeRecordingBinaryOp) \
V(StringAdd) \
+ V(StringCharAt) \
V(SubString) \
V(StringCompare) \
V(SmiOp) \
V(Compare) \
+ V(CompareIC) \
+ V(MathPow) \
+ V(TranscendentalCache) \
V(RecordWrite) \
V(ConvertToDouble) \
V(WriteInt32ToHeapNumber) \
@@ -52,7 +56,6 @@ namespace internal {
V(FastNewClosure) \
V(FastNewContext) \
V(FastCloneShallowArray) \
- V(TranscendentalCache) \
V(GenericUnaryOp) \
V(RevertToNumber) \
V(ToBoolean) \
@@ -60,6 +63,7 @@ namespace internal {
V(CounterOp) \
V(ArgumentsAccess) \
V(RegExpExec) \
+ V(RegExpConstructResult) \
V(NumberToString) \
V(CEntry) \
V(JSEntry) \
@@ -125,7 +129,7 @@ class CodeStub BASE_EMBEDDED {
virtual ~CodeStub() {}
protected:
- static const int kMajorBits = 5;
+ static const int kMajorBits = 6;
static const int kMinorBits = kBitsPerInt - kSmiTagSize - kMajorBits;
private:
@@ -143,6 +147,9 @@ class CodeStub BASE_EMBEDDED {
// initially generated.
void RecordCodeGeneration(Code* code, MacroAssembler* masm);
+ // Finish the code object after it has been generated.
+ virtual void FinishCode(Code* code) { }
+
// Returns information for computing the number key.
virtual Major MajorKey() = 0;
virtual int MinorKey() = 0;
@@ -216,11 +223,11 @@ namespace v8 {
namespace internal {
-// RuntimeCallHelper implementation used in IC stubs: enters/leaves a
+// RuntimeCallHelper implementation used in stubs: enters/leaves a
// newly created internal frame before/after the runtime call.
-class ICRuntimeCallHelper : public RuntimeCallHelper {
+class StubRuntimeCallHelper : public RuntimeCallHelper {
public:
- ICRuntimeCallHelper() {}
+ StubRuntimeCallHelper() {}
virtual void BeforeCall(MacroAssembler* masm) const;
@@ -318,13 +325,24 @@ class FastCloneShallowArrayStub : public CodeStub {
class InstanceofStub: public CodeStub {
public:
- InstanceofStub() { }
+ enum Flags {
+ kNoFlags = 0,
+ kArgsInRegisters = 1 << 0
+ };
+
+ explicit InstanceofStub(Flags flags) : flags_(flags) { }
void Generate(MacroAssembler* masm);
private:
Major MajorKey() { return Instanceof; }
- int MinorKey() { return 0; }
+ int MinorKey() { return args_in_registers() ? 1 : 0; }
+
+ bool args_in_registers() {
+ return (flags_ & kArgsInRegisters) != 0;
+ }
+
+ Flags flags_;
};
@@ -376,9 +394,61 @@ class GenericUnaryOpStub : public CodeStub {
};
-enum NaNInformation {
- kBothCouldBeNaN,
- kCantBothBeNaN
+class MathPowStub: public CodeStub {
+ public:
+ MathPowStub() {}
+ virtual void Generate(MacroAssembler* masm);
+
+ private:
+ virtual CodeStub::Major MajorKey() { return MathPow; }
+ virtual int MinorKey() { return 0; }
+
+ const char* GetName() { return "MathPowStub"; }
+};
+
+
+class StringCharAtStub: public CodeStub {
+ public:
+ StringCharAtStub() {}
+
+ private:
+ Major MajorKey() { return StringCharAt; }
+ int MinorKey() { return 0; }
+
+ void Generate(MacroAssembler* masm);
+};
+
+
+class ICCompareStub: public CodeStub {
+ public:
+ ICCompareStub(Token::Value op, CompareIC::State state)
+ : op_(op), state_(state) {
+ ASSERT(Token::IsCompareOp(op));
+ }
+
+ virtual void Generate(MacroAssembler* masm);
+
+ private:
+ class OpField: public BitField<int, 0, 3> { };
+ class StateField: public BitField<int, 3, 5> { };
+
+ virtual void FinishCode(Code* code) { code->set_compare_state(state_); }
+
+ virtual CodeStub::Major MajorKey() { return CompareIC; }
+ virtual int MinorKey();
+
+ virtual int GetCodeKind() { return Code::COMPARE_IC; }
+
+ void GenerateSmis(MacroAssembler* masm);
+ void GenerateHeapNumbers(MacroAssembler* masm);
+ void GenerateObjects(MacroAssembler* masm);
+ void GenerateMiss(MacroAssembler* masm);
+
+ bool strict() const { return op_ == Token::EQ_STRICT; }
+ Condition GetCondition() const { return CompareIC::ComputeCondition(op_); }
+
+ Token::Value op_;
+ CompareIC::State state_;
};
@@ -391,6 +461,12 @@ enum CompareFlags {
};
+enum NaNInformation {
+ kBothCouldBeNaN,
+ kCantBothBeNaN
+};
+
+
class CompareStub: public CodeStub {
public:
CompareStub(Condition cc,
@@ -398,7 +474,7 @@ class CompareStub: public CodeStub {
CompareFlags flags,
Register lhs,
Register rhs) :
- cc_(cc),
+ cc_(cc),
strict_(strict),
never_nan_nan_((flags & CANT_BOTH_BE_NAN) != 0),
include_number_compare_((flags & NO_NUMBER_COMPARE_IN_STUB) == 0),
@@ -440,6 +516,7 @@ class CompareStub: public CodeStub {
// Register holding the left hand side of the comparison if the stub gives
// a choice, no_reg otherwise.
+
Register lhs_;
// Register holding the right hand side of the comparison if the stub gives
// a choice, no_reg otherwise.
@@ -457,6 +534,11 @@ class CompareStub: public CodeStub {
int MinorKey();
+ virtual int GetCodeKind() { return Code::COMPARE_IC; }
+ virtual void FinishCode(Code* code) {
+ code->set_compare_state(CompareIC::GENERIC);
+ }
+
// Branch to the label if the given object isn't a symbol.
void BranchIfNonSymbol(MacroAssembler* masm,
Label* label,
@@ -490,9 +572,11 @@ class CompareStub: public CodeStub {
class CEntryStub : public CodeStub {
public:
- explicit CEntryStub(int result_size) : result_size_(result_size) { }
+ explicit CEntryStub(int result_size)
+ : result_size_(result_size), save_doubles_(false) { }
void Generate(MacroAssembler* masm);
+ void SaveDoubles() { save_doubles_ = true; }
private:
void GenerateCore(MacroAssembler* masm,
@@ -508,10 +592,9 @@ class CEntryStub : public CodeStub {
// Number of pointers/values returned.
const int result_size_;
+ bool save_doubles_;
Major MajorKey() { return CEntry; }
- // Minor key must differ if different result_size_ values means different
- // code is generated.
int MinorKey();
const char* GetName() { return "CEntryStub"; }
@@ -597,6 +680,26 @@ class RegExpExecStub: public CodeStub {
};
+class RegExpConstructResultStub: public CodeStub {
+ public:
+ RegExpConstructResultStub() { }
+
+ private:
+ Major MajorKey() { return RegExpConstructResult; }
+ int MinorKey() { return 0; }
+
+ void Generate(MacroAssembler* masm);
+
+ const char* GetName() { return "RegExpConstructResultStub"; }
+
+#ifdef DEBUG
+ void Print() {
+ PrintF("RegExpConstructResultStub\n");
+ }
+#endif
+};
+
+
class CallFunctionStub: public CodeStub {
public:
CallFunctionStub(int argc, InLoopFlag in_loop, CallFunctionFlags flags)