Index: src/code-stubs.cc |
diff --git a/src/code-stubs.cc b/src/code-stubs.cc |
index 3f26e3fa7151ae91be2ce58df3939fb158296295..3fb61534287c1ab7b1075cde2c58844be3e16ae3 100644 |
--- a/src/code-stubs.cc |
+++ b/src/code-stubs.cc |
@@ -217,479 +217,32 @@ void CodeStub::PrintName(StringStream* stream) { |
} |
-void BinaryOpStub::PrintBaseName(StringStream* stream) { |
- const char* op_name = Token::Name(op_); |
- const char* ovr = ""; |
- if (mode_ == OVERWRITE_LEFT) ovr = "_ReuseLeft"; |
- if (mode_ == OVERWRITE_RIGHT) ovr = "_ReuseRight"; |
- stream->Add("BinaryOpStub_%s%s", op_name, ovr); |
-} |
- |
- |
-void BinaryOpStub::PrintState(StringStream* stream) { |
- stream->Add("("); |
- stream->Add(StateToName(left_state_)); |
- stream->Add("*"); |
- if (fixed_right_arg_.has_value) { |
- stream->Add("%d", fixed_right_arg_.value); |
- } else { |
- stream->Add(StateToName(right_state_)); |
- } |
- stream->Add("->"); |
- stream->Add(StateToName(result_state_)); |
- stream->Add(")"); |
-} |
- |
- |
-Maybe<Handle<Object> > BinaryOpStub::Result(Handle<Object> left, |
- Handle<Object> right, |
- Isolate* isolate) { |
- Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object()); |
- Builtins::JavaScript func = BinaryOpIC::TokenToJSBuiltin(op_); |
- Object* builtin = builtins->javascript_builtin(func); |
- Handle<JSFunction> builtin_function = |
- Handle<JSFunction>(JSFunction::cast(builtin), isolate); |
- bool caught_exception; |
- Handle<Object> result = Execution::Call(isolate, builtin_function, left, |
- 1, &right, &caught_exception); |
- return Maybe<Handle<Object> >(!caught_exception, result); |
-} |
- |
- |
-void BinaryOpStub::Initialize() { |
- fixed_right_arg_.has_value = false; |
- left_state_ = right_state_ = result_state_ = NONE; |
-} |
- |
- |
-void BinaryOpStub::Generate(Token::Value op, |
- State left, |
- State right, |
- State result, |
- OverwriteMode mode, |
- Isolate* isolate) { |
- BinaryOpStub stub(INITIALIZED); |
- stub.op_ = op; |
- stub.left_state_ = left; |
- stub.right_state_ = right; |
- stub.result_state_ = result; |
- stub.mode_ = mode; |
- stub.GetCode(isolate); |
-} |
- |
- |
-void BinaryOpStub::Generate(Token::Value op, |
- State left, |
- int right, |
- State result, |
- OverwriteMode mode, |
- Isolate* isolate) { |
- BinaryOpStub stub(INITIALIZED); |
- stub.op_ = op; |
- stub.left_state_ = left; |
- stub.fixed_right_arg_.has_value = true; |
- stub.fixed_right_arg_.value = right; |
- stub.right_state_ = SMI; |
- stub.result_state_ = result; |
- stub.mode_ = mode; |
- stub.GetCode(isolate); |
-} |
- |
- |
-void BinaryOpStub::GenerateAheadOfTime(Isolate* isolate) { |
- Token::Value binop[] = {Token::SUB, Token::MOD, Token::DIV, Token::MUL, |
- Token::ADD, Token::SAR, Token::BIT_OR, Token::BIT_AND, |
- Token::BIT_XOR, Token::SHL, Token::SHR}; |
- for (unsigned i = 0; i < ARRAY_SIZE(binop); i++) { |
- BinaryOpStub stub(UNINITIALIZED); |
- stub.op_ = binop[i]; |
- stub.GetCode(isolate); |
- } |
- |
- // TODO(olivf) We should investigate why adding stubs to the snapshot is so |
- // expensive at runtime. When solved we should be able to add most binops to |
- // the snapshot instead of hand-picking them. |
- // Generated list of commonly used stubs |
- Generate(Token::ADD, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, INT32, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, INT32, INT32, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, INT32, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, INT32, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, INT32, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::ADD, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::ADD, NUMBER, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, NUMBER, INT32, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, NUMBER, INT32, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::ADD, NUMBER, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, NUMBER, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, NUMBER, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::ADD, NUMBER, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, NUMBER, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, NUMBER, SMI, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::ADD, SMI, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, SMI, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, SMI, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, SMI, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::ADD, SMI, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, SMI, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::ADD, SMI, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::ADD, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_AND, INT32, INT32, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, INT32, INT32, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, INT32, INT32, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, INT32, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, INT32, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_AND, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, NUMBER, INT32, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, NUMBER, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, SMI, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, SMI, INT32, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, SMI, NUMBER, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_AND, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_AND, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_AND, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, INT32, INT32, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, INT32, INT32, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_OR, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, INT32, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_OR, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, NUMBER, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_OR, NUMBER, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, NUMBER, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_OR, NUMBER, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, SMI, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, SMI, INT32, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, SMI, INT32, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_OR, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_OR, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_XOR, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_XOR, INT32, INT32, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_XOR, INT32, INT32, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, INT32, INT32, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_XOR, INT32, NUMBER, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_XOR, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::BIT_XOR, NUMBER, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, NUMBER, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, SMI, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, SMI, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_XOR, SMI, INT32, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_XOR, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::BIT_XOR, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::BIT_XOR, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::DIV, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, INT32, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, INT32, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, INT32, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, INT32, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, NUMBER, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, NUMBER, INT32, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, NUMBER, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, NUMBER, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, NUMBER, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::DIV, NUMBER, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, NUMBER, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, SMI, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, SMI, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, SMI, INT32, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, SMI, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, SMI, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, SMI, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::DIV, SMI, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, SMI, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, SMI, SMI, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::DIV, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::DIV, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::DIV, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::MOD, NUMBER, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MOD, SMI, 16, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::MOD, SMI, 2, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MOD, SMI, 2048, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MOD, SMI, 32, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MOD, SMI, 4, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MOD, SMI, 4, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::MOD, SMI, 8, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MOD, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MOD, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, INT32, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, INT32, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, INT32, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, INT32, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, NUMBER, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, NUMBER, INT32, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, NUMBER, INT32, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::MUL, NUMBER, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, NUMBER, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, NUMBER, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, NUMBER, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, NUMBER, SMI, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::MUL, SMI, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, SMI, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, SMI, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, SMI, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, SMI, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, SMI, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::MUL, SMI, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, SMI, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, SMI, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::MUL, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::MUL, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SAR, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SAR, INT32, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SAR, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SAR, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SAR, NUMBER, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SAR, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::SAR, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHL, INT32, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::SHL, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHL, INT32, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SHL, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHL, NUMBER, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHL, SMI, SMI, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::SHL, SMI, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::SHL, SMI, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHL, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SHL, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::SHL, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHR, INT32, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SHR, INT32, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::SHR, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHR, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SHR, NUMBER, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::SHR, NUMBER, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SHR, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SHR, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::SHR, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SUB, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, INT32, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, INT32, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SUB, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SUB, NUMBER, INT32, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, NUMBER, INT32, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, NUMBER, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, NUMBER, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, NUMBER, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SUB, NUMBER, SMI, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, NUMBER, SMI, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, NUMBER, SMI, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SUB, SMI, INT32, INT32, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, SMI, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, SMI, NUMBER, NUMBER, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, SMI, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
- Generate(Token::SUB, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
- Generate(Token::SUB, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
- Generate(Token::SUB, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
-} |
- |
- |
-bool BinaryOpStub::can_encode_arg_value(int32_t value) const { |
- return op_ == Token::MOD && value > 0 && IsPowerOf2(value) && |
- FixedRightArgValueBits::is_valid(WhichPowerOf2(value)); |
-} |
- |
- |
-int BinaryOpStub::encode_arg_value(int32_t value) const { |
- ASSERT(can_encode_arg_value(value)); |
- return WhichPowerOf2(value); |
-} |
- |
- |
-int32_t BinaryOpStub::decode_arg_value(int value) const { |
- return 1 << value; |
-} |
- |
- |
-int BinaryOpStub::encode_token(Token::Value op) const { |
- ASSERT(op >= FIRST_TOKEN && op <= LAST_TOKEN); |
- return op - FIRST_TOKEN; |
-} |
- |
- |
-Token::Value BinaryOpStub::decode_token(int op) const { |
- int res = op + FIRST_TOKEN; |
- ASSERT(res >= FIRST_TOKEN && res <= LAST_TOKEN); |
- return static_cast<Token::Value>(res); |
-} |
- |
- |
-const char* BinaryOpStub::StateToName(State state) { |
- switch (state) { |
- case NONE: |
- return "None"; |
- case SMI: |
- return "Smi"; |
- case INT32: |
- return "Int32"; |
- case NUMBER: |
- return "Number"; |
- case STRING: |
- return "String"; |
- case GENERIC: |
- return "Generic"; |
- } |
- return ""; |
-} |
- |
- |
-void BinaryOpStub::UpdateStatus(Handle<Object> left, |
- Handle<Object> right, |
- Maybe<Handle<Object> > result) { |
- int old_state = GetExtraICState(); |
- |
- UpdateStatus(left, &left_state_); |
- UpdateStatus(right, &right_state_); |
- |
- int32_t value; |
- bool new_has_fixed_right_arg = |
- right->ToInt32(&value) && can_encode_arg_value(value) && |
- (left_state_ == SMI || left_state_ == INT32) && |
- (result_state_ == NONE || !fixed_right_arg_.has_value); |
- |
- fixed_right_arg_ = Maybe<int32_t>(new_has_fixed_right_arg, value); |
- |
- if (result.has_value) UpdateStatus(result.value, &result_state_); |
- |
- State max_input = Max(left_state_, right_state_); |
- |
- if (!has_int_result() && op_ != Token::SHR && |
- max_input <= NUMBER && max_input > result_state_) { |
- result_state_ = max_input; |
- } |
- |
- ASSERT(result_state_ <= (has_int_result() ? INT32 : NUMBER) || |
- op_ == Token::ADD); |
- |
- // Reset overwrite mode unless we can actually make use of it, or may be able |
- // to make use of it at some point in the future. |
- if ((mode_ == OVERWRITE_LEFT && left_state_ > NUMBER) || |
- (mode_ == OVERWRITE_RIGHT && right_state_ > NUMBER) || |
- result_state_ > NUMBER) { |
- mode_ = NO_OVERWRITE; |
- } |
- |
- if (old_state == GetExtraICState()) { |
- // Tagged operations can lead to non-truncating HChanges |
- if (left->IsUndefined() || left->IsBoolean()) { |
- left_state_ = GENERIC; |
- } else if (right->IsUndefined() || right->IsBoolean()) { |
- right_state_ = GENERIC; |
- } else { |
- // Since the fpu is to precise, we might bail out on numbers which |
- // actually would truncate with 64 bit precision. |
- ASSERT(!CpuFeatures::IsSupported(SSE2) && |
- result_state_ <= INT32); |
- result_state_ = NUMBER; |
+// static |
+void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { |
+ // Generate the uninitialized versions of the stub. |
+ for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { |
+ for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { |
+ BinaryOpICStub stub(static_cast<Token::Value>(op), |
+ static_cast<OverwriteMode>(mode)); |
+ stub.GetCode(isolate); |
} |
} |
-} |
- |
- |
-void BinaryOpStub::UpdateStatus(Handle<Object> object, |
- State* state) { |
- bool is_truncating = (op_ == Token::BIT_AND || op_ == Token::BIT_OR || |
- op_ == Token::BIT_XOR || op_ == Token::SAR || |
- op_ == Token::SHL || op_ == Token::SHR); |
- v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(object); |
- if (object->IsBoolean() && is_truncating) { |
- // Booleans are converted by truncating by HChange. |
- type = TypeInfo::Integer32(); |
- } |
- if (object->IsUndefined()) { |
- // Undefined will be automatically truncated for us by HChange. |
- type = is_truncating ? TypeInfo::Integer32() : TypeInfo::Double(); |
- } |
- State int_state = SmiValuesAre32Bits() ? NUMBER : INT32; |
- State new_state = NONE; |
- if (type.IsSmi()) { |
- new_state = SMI; |
- } else if (type.IsInteger32()) { |
- new_state = int_state; |
- } else if (type.IsNumber()) { |
- new_state = NUMBER; |
- } else if (object->IsString() && operation() == Token::ADD) { |
- new_state = STRING; |
- } else { |
- new_state = GENERIC; |
- } |
- if ((new_state <= NUMBER && *state > NUMBER) || |
- (new_state > NUMBER && *state <= NUMBER && *state != NONE)) { |
- new_state = GENERIC; |
- } |
- *state = Max(*state, new_state); |
-} |
- |
- |
-Handle<Type> BinaryOpStub::StateToType(State state, |
- Isolate* isolate) { |
- Handle<Type> t = handle(Type::None(), isolate); |
- switch (state) { |
- case NUMBER: |
- t = handle(Type::Union(t, handle(Type::Double(), isolate)), isolate); |
- // Fall through. |
- case INT32: |
- t = handle(Type::Union(t, handle(Type::Signed32(), isolate)), isolate); |
- // Fall through. |
- case SMI: |
- t = handle(Type::Union(t, handle(Type::Smi(), isolate)), isolate); |
- break; |
- case STRING: |
- t = handle(Type::Union(t, handle(Type::String(), isolate)), isolate); |
- break; |
- case GENERIC: |
- return handle(Type::Any(), isolate); |
- break; |
- case NONE: |
- break; |
- } |
- return t; |
+ // Generate special versions of the stub. |
+ BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
} |
-Handle<Type> BinaryOpStub::GetLeftType(Isolate* isolate) const { |
- return StateToType(left_state_, isolate); |
-} |
- |
- |
-Handle<Type> BinaryOpStub::GetRightType(Isolate* isolate) const { |
- return StateToType(right_state_, isolate); |
+void BinaryOpICStub::PrintState(StringStream* stream) { |
+ state_.Print(stream); |
} |
-Handle<Type> BinaryOpStub::GetResultType(Isolate* isolate) const { |
- if (HasSideEffects(isolate)) return StateToType(NONE, isolate); |
- if (result_state_ == GENERIC && op_ == Token::ADD) { |
- return handle(Type::Union(handle(Type::Number(), isolate), |
- handle(Type::String(), isolate)), isolate); |
- } |
- ASSERT(result_state_ != GENERIC); |
- if (result_state_ == NUMBER && op_ == Token::SHR) { |
- return handle(Type::Unsigned32(), isolate); |
- } |
- return StateToType(result_state_, isolate); |
+// static |
+void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, |
+ const BinaryOpIC::State& state) { |
+ BinaryOpICStub stub(state); |
+ stub.GetCode(isolate); |
} |
@@ -1166,6 +719,13 @@ void FastNewClosureStub::InstallDescriptors(Isolate* isolate) { |
// static |
+void BinaryOpICStub::InstallDescriptors(Isolate* isolate) { |
+ BinaryOpICStub stub(Token::ADD, NO_OVERWRITE); |
+ InstallDescriptor(isolate, &stub); |
+} |
+ |
+ |
+// static |
void NewStringAddStub::InstallDescriptors(Isolate* isolate) { |
NewStringAddStub stub(STRING_ADD_CHECK_NONE, NOT_TENURED); |
InstallDescriptor(isolate, &stub); |