Added two convenience methods to access an int/double argument from within a

runtime function and use these in various places.
Review URL: http://codereview.chromium.org/7003114

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8263 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5a236ce6
......@@ -63,6 +63,14 @@ class Arguments BASE_EMBEDDED {
return Handle<S>(reinterpret_cast<S**>(value));
}
int smi_at(int index) {
return Smi::cast((*this)[index])->value();
}
double number_at(int index) {
return (*this)[index]->Number();
}
// Get the total number of arguments including the receiver.
int length() const { return length_; }
......
......@@ -578,13 +578,7 @@ bool CallICBase::TryUpdateExtraICState(LookupResult* lookup,
// out of bounds, update the state to record this fact.
if (StringStubState::decode(*extra_ic_state) == DEFAULT_STRING_STUB &&
argc >= 1 && args[1]->IsNumber()) {
double index;
if (args[1]->IsSmi()) {
index = Smi::cast(args[1])->value();
} else {
ASSERT(args[1]->IsHeapNumber());
index = DoubleToInteger(HeapNumber::cast(args[1])->value());
}
double index = DoubleToInteger(args.number_at(1));
if (index < 0 || index >= string->length()) {
*extra_ic_state =
StringStubState::update(*extra_ic_state,
......@@ -2294,10 +2288,10 @@ RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) {
HandleScope scope(isolate);
Handle<Object> operand = args.at<Object>(0);
int key = Smi::cast(args[1])->value();
Token::Value op = static_cast<Token::Value>(Smi::cast(args[2])->value());
int key = args.smi_at(1);
Token::Value op = static_cast<Token::Value>(args.smi_at(2));
UnaryOpIC::TypeInfo previous_type =
static_cast<UnaryOpIC::TypeInfo>(Smi::cast(args[3])->value());
static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3));
UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand);
type = UnaryOpIC::ComputeNewType(type, previous_type);
......@@ -2346,10 +2340,10 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
HandleScope scope(isolate);
Handle<Object> left = args.at<Object>(0);
Handle<Object> right = args.at<Object>(1);
int key = Smi::cast(args[2])->value();
Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value());
int key = args.smi_at(2);
Token::Value op = static_cast<Token::Value>(args.smi_at(3));
BinaryOpIC::TypeInfo previous_type =
static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value());
static_cast<BinaryOpIC::TypeInfo>(args.smi_at(4));
BinaryOpIC::TypeInfo type = BinaryOpIC::GetTypeInfo(left, right);
type = BinaryOpIC::JoinTypes(type, previous_type);
......@@ -2509,7 +2503,7 @@ CompareIC::State CompareIC::TargetState(State state,
RUNTIME_FUNCTION(Code*, CompareIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 3);
CompareIC ic(isolate, static_cast<Token::Value>(Smi::cast(args[2])->value()));
CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2)));
ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
return ic.target();
}
......
This diff is collapsed.
......@@ -1370,8 +1370,7 @@ RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) {
JSObject* recv = JSObject::cast(args[0]);
String* name = String::cast(args[1]);
Object* value = args[2];
StrictModeFlag strict_mode =
static_cast<StrictModeFlag>(Smi::cast(args[3])->value());
StrictModeFlag strict_mode = static_cast<StrictModeFlag>(args.smi_at(3));
ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode);
ASSERT(recv->HasNamedInterceptor());
PropertyAttributes attr = NONE;
......@@ -1383,8 +1382,8 @@ RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) {
RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor) {
JSObject* receiver = JSObject::cast(args[0]);
ASSERT(Smi::cast(args[1])->value() >= 0);
uint32_t index = Smi::cast(args[1])->value();
ASSERT(args.smi_at(1) >= 0);
uint32_t index = args.smi_at(1);
return receiver->GetElementWithInterceptor(receiver, index);
}
......
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