Clean up runtime functions.

Make all functions called from generated code declared using
RUNTIME_FUNCTION macro. This makes them all look consistent and allows
experimenting with various calling conventions.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7439 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vitalyr@chromium.org 2011-03-30 14:17:39 +00:00
parent b64e85d241
commit a051955678
8 changed files with 375 additions and 699 deletions

View File

@ -99,8 +99,17 @@ class CustomArguments : public Relocatable {
Object* values_[3];
};
#define RUNTIME_CALLING_CONVENTION Arguments args, Isolate* isolate
#define RUNTIME_GET_ISOLATE ASSERT(isolate == Isolate::Current())
#define DECLARE_RUNTIME_FUNCTION(Type, Name) \
Type Name(Arguments args, Isolate* isolate)
#define RUNTIME_FUNCTION(Type, Name) \
Type Name(Arguments args, Isolate* isolate)
#define RUNTIME_ARGUMENTS(isolate, args) args, isolate
} } // namespace v8::internal

View File

@ -1002,7 +1002,7 @@ ExternalReference ExternalReference::compare_doubles(Isolate* isolate) {
#ifdef ENABLE_DEBUGGER_SUPPORT
ExternalReference ExternalReference::debug_break(Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug::Break)));
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug_Break)));
}

View File

@ -917,24 +917,20 @@ void Debug::Iterate(ObjectVisitor* v) {
}
// This remains a static method so that generated code can call it.
Object* Debug::Break(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
Debug* debug = isolate->debug();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
Object* Debug::Break(Arguments args) {
Heap* heap = isolate_->heap();
HandleScope scope(isolate_);
ASSERT(args.length() == 0);
debug->thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED;
thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED;
// Get the top-most JavaScript frame.
JavaScriptFrameIterator it;
JavaScriptFrame* frame = it.frame();
// Just continue if breaks are disabled or debugger cannot be loaded.
if (debug->disable_break() || !debug->Load()) {
debug->SetAfterBreakTarget(frame);
if (disable_break() || !Load()) {
SetAfterBreakTarget(frame);
return heap->undefined_value();
}
@ -945,7 +941,7 @@ Object* Debug::Break(RUNTIME_CALLING_CONVENTION) {
}
// Postpone interrupt during breakpoint processing.
PostponeInterruptsScope postpone(isolate);
PostponeInterruptsScope postpone(isolate_);
// Get the debug info (create it if it does not exist).
Handle<SharedFunctionInfo> shared =
@ -958,10 +954,10 @@ Object* Debug::Break(RUNTIME_CALLING_CONVENTION) {
break_location_iterator.FindBreakLocationFromAddress(frame->pc());
// Check whether step next reached a new statement.
if (!debug->StepNextContinue(&break_location_iterator, frame)) {
if (!StepNextContinue(&break_location_iterator, frame)) {
// Decrease steps left if performing multiple steps.
if (debug->thread_local_.step_count_ > 0) {
debug->thread_local_.step_count_--;
if (thread_local_.step_count_ > 0) {
thread_local_.step_count_--;
}
}
@ -971,56 +967,55 @@ Object* Debug::Break(RUNTIME_CALLING_CONVENTION) {
if (break_location_iterator.HasBreakPoint()) {
Handle<Object> break_point_objects =
Handle<Object>(break_location_iterator.BreakPointObjects());
break_points_hit = debug->CheckBreakPoints(break_point_objects);
break_points_hit = CheckBreakPoints(break_point_objects);
}
// If step out is active skip everything until the frame where we need to step
// out to is reached, unless real breakpoint is hit.
if (debug->StepOutActive() && frame->fp() != debug->step_out_fp() &&
if (StepOutActive() && frame->fp() != step_out_fp() &&
break_points_hit->IsUndefined() ) {
// Step count should always be 0 for StepOut.
ASSERT(debug->thread_local_.step_count_ == 0);
ASSERT(thread_local_.step_count_ == 0);
} else if (!break_points_hit->IsUndefined() ||
(debug->thread_local_.last_step_action_ != StepNone &&
debug->thread_local_.step_count_ == 0)) {
(thread_local_.last_step_action_ != StepNone &&
thread_local_.step_count_ == 0)) {
// Notify debugger if a real break point is triggered or if performing
// single stepping with no more steps to perform. Otherwise do another step.
// Clear all current stepping setup.
debug->ClearStepping();
ClearStepping();
// Notify the debug event listeners.
isolate->debugger()->OnDebugBreak(break_points_hit, false);
} else if (debug->thread_local_.last_step_action_ != StepNone) {
isolate_->debugger()->OnDebugBreak(break_points_hit, false);
} else if (thread_local_.last_step_action_ != StepNone) {
// Hold on to last step action as it is cleared by the call to
// ClearStepping.
StepAction step_action = debug->thread_local_.last_step_action_;
int step_count = debug->thread_local_.step_count_;
StepAction step_action = thread_local_.last_step_action_;
int step_count = thread_local_.step_count_;
// Clear all current stepping setup.
debug->ClearStepping();
ClearStepping();
// Set up for the remaining steps.
debug->PrepareStep(step_action, step_count);
PrepareStep(step_action, step_count);
}
if (debug->thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) {
debug->SetAfterBreakTarget(frame);
} else if (debug->thread_local_.frame_drop_mode_ ==
if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) {
SetAfterBreakTarget(frame);
} else if (thread_local_.frame_drop_mode_ ==
FRAME_DROPPED_IN_IC_CALL) {
// We must have been calling IC stub. Do not go there anymore.
Code* plain_return =
Isolate::Current()->builtins()->builtin(
Builtins::kPlainReturn_LiveEdit);
debug->thread_local_.after_break_target_ = plain_return->entry();
} else if (debug->thread_local_.frame_drop_mode_ ==
Code* plain_return = isolate_->builtins()->builtin(
Builtins::kPlainReturn_LiveEdit);
thread_local_.after_break_target_ = plain_return->entry();
} else if (thread_local_.frame_drop_mode_ ==
FRAME_DROPPED_IN_DEBUG_SLOT_CALL) {
// Debug break slot stub does not return normally, instead it manually
// cleans the stack and jumps. We should patch the jump address.
Code* plain_return = Isolate::Current()->builtins()->builtin(
Code* plain_return = isolate_->builtins()->builtin(
Builtins::kFrameDropper_LiveEdit);
debug->thread_local_.after_break_target_ = plain_return->entry();
} else if (debug->thread_local_.frame_drop_mode_ ==
thread_local_.after_break_target_ = plain_return->entry();
} else if (thread_local_.frame_drop_mode_ ==
FRAME_DROPPED_IN_DIRECT_CALL) {
// Nothing to do, after_break_target is not used here.
} else {
@ -1031,6 +1026,11 @@ Object* Debug::Break(RUNTIME_CALLING_CONVENTION) {
}
RUNTIME_FUNCTION(Object*, Debug_Break) {
return isolate->debug()->Break(args);
}
// Check the break point objects for whether one or more are actually
// triggered. This function returns a JSArray with the break point objects
// which is triggered.

View File

@ -228,7 +228,7 @@ class Debug {
void PreemptionWhileInDebugger();
void Iterate(ObjectVisitor* v);
static Object* Break(RUNTIME_CALLING_CONVENTION);
Object* Break(Arguments args);
void SetBreakPoint(Handle<SharedFunctionInfo> shared,
Handle<Object> break_point_object,
int* source_position);
@ -548,6 +548,9 @@ class Debug {
};
DECLARE_RUNTIME_FUNCTION(Object*, Debug_Break);
// Message delivered to the message handler callback. This is either a debugger
// event or the response to a command.
class MessageImpl: public v8::Debug::Message {

View File

@ -1815,8 +1815,7 @@ static JSFunction* CompileFunction(Isolate* isolate,
// Used from ic-<arch>.cc.
MUST_USE_RESULT MaybeObject* CallIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, CallIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
CallIC ic(isolate);
@ -1846,8 +1845,7 @@ MUST_USE_RESULT MaybeObject* CallIC_Miss(RUNTIME_CALLING_CONVENTION) {
// Used from ic-<arch>.cc.
MUST_USE_RESULT MaybeObject* KeyedCallIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
KeyedCallIC ic(isolate);
@ -1868,8 +1866,7 @@ MUST_USE_RESULT MaybeObject* KeyedCallIC_Miss(RUNTIME_CALLING_CONVENTION) {
// Used from ic-<arch>.cc.
MUST_USE_RESULT MaybeObject* LoadIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, LoadIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
LoadIC ic(isolate);
@ -1879,8 +1876,7 @@ MUST_USE_RESULT MaybeObject* LoadIC_Miss(RUNTIME_CALLING_CONVENTION) {
// Used from ic-<arch>.cc
MUST_USE_RESULT MaybeObject* KeyedLoadIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
KeyedLoadIC ic(isolate);
@ -1890,8 +1886,7 @@ MUST_USE_RESULT MaybeObject* KeyedLoadIC_Miss(RUNTIME_CALLING_CONVENTION) {
// Used from ic-<arch>.cc.
MUST_USE_RESULT MaybeObject* StoreIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 3);
StoreIC ic(isolate);
@ -1905,8 +1900,7 @@ MUST_USE_RESULT MaybeObject* StoreIC_Miss(RUNTIME_CALLING_CONVENTION) {
}
MUST_USE_RESULT MaybeObject* StoreIC_ArrayLength(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) {
NoHandleAllocation nha;
ASSERT(args.length() == 2);
@ -1927,9 +1921,7 @@ MUST_USE_RESULT MaybeObject* StoreIC_ArrayLength(RUNTIME_CALLING_CONVENTION) {
// Extend storage is called in a store inline cache when
// it is necessary to extend the properties array of a
// JSObject.
MUST_USE_RESULT MaybeObject* SharedStoreIC_ExtendStorage(
RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, SharedStoreIC_ExtendStorage) {
NoHandleAllocation na;
ASSERT(args.length() == 3);
@ -1963,8 +1955,7 @@ MUST_USE_RESULT MaybeObject* SharedStoreIC_ExtendStorage(
// Used from ic-<arch>.cc.
MUST_USE_RESULT MaybeObject* KeyedStoreIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 3);
KeyedStoreIC ic(isolate);
@ -2037,8 +2028,7 @@ BinaryOpIC::TypeInfo BinaryOpIC::GetTypeInfo(Object* left,
Handle<Code> GetBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info);
MUST_USE_RESULT MaybeObject* BinaryOp_Patch(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
ASSERT(args.length() == 5);
HandleScope scope(isolate);
@ -2209,8 +2199,7 @@ Handle<Code> GetTypeRecordingBinaryOpStub(int key,
TRBinaryOpIC::TypeInfo result_type);
MaybeObject* TypeRecordingBinaryOp_Patch(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, TypeRecordingBinaryOp_Patch) {
ASSERT(args.length() == 5);
HandleScope scope(isolate);
@ -2365,8 +2354,7 @@ CompareIC::State CompareIC::TargetState(State state,
// Used from ic_<arch>.cc.
Code* CompareIC_Miss(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(Code*, CompareIC_Miss) {
NoHandleAllocation na;
ASSERT(args.length() == 3);
CompareIC ic(isolate, static_cast<Token::Value>(Smi::cast(args[2])->value()));

File diff suppressed because it is too large Load Diff

View File

@ -1278,8 +1278,7 @@ void StubCache::CollectMatchingMaps(ZoneMapList* types,
// StubCompiler implementation.
MaybeObject* LoadCallbackProperty(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty) {
ASSERT(args[0]->IsJSObject());
ASSERT(args[1]->IsJSObject());
AccessorInfo* callback = AccessorInfo::cast(args[3]);
@ -1301,8 +1300,7 @@ MaybeObject* LoadCallbackProperty(RUNTIME_CALLING_CONVENTION) {
}
MaybeObject* StoreCallbackProperty(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty) {
JSObject* recv = JSObject::cast(args[0]);
AccessorInfo* callback = AccessorInfo::cast(args[1]);
Address setter_address = v8::ToCData<Address>(callback->setter());
@ -1335,8 +1333,7 @@ static const int kAccessorInfoOffsetInInterceptorArgs = 2;
* Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't
* provide any value for the given name.
*/
MaybeObject* LoadPropertyWithInterceptorOnly(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) {
Handle<String> name_handle = args.at<String>(0);
Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1);
ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2);
@ -1435,8 +1432,7 @@ static MaybeObject* LoadWithInterceptor(Arguments* args,
* Loads a property with an interceptor performing post interceptor
* lookup if interceptor failed.
*/
MaybeObject* LoadPropertyWithInterceptorForLoad(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad) {
PropertyAttributes attr = NONE;
Object* result;
{ MaybeObject* maybe_result = LoadWithInterceptor(&args, &attr);
@ -1449,8 +1445,7 @@ MaybeObject* LoadPropertyWithInterceptorForLoad(RUNTIME_CALLING_CONVENTION) {
}
MaybeObject* LoadPropertyWithInterceptorForCall(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall) {
PropertyAttributes attr;
MaybeObject* result = LoadWithInterceptor(&args, &attr);
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@ -1461,8 +1456,7 @@ MaybeObject* LoadPropertyWithInterceptorForCall(RUNTIME_CALLING_CONVENTION) {
}
MaybeObject* StoreInterceptorProperty(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty) {
ASSERT(args.length() == 4);
JSObject* recv = JSObject::cast(args[0]);
String* name = String::cast(args[1]);
@ -1478,8 +1472,7 @@ MaybeObject* StoreInterceptorProperty(RUNTIME_CALLING_CONVENTION) {
}
MaybeObject* KeyedLoadPropertyWithInterceptor(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
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();

View File

@ -392,17 +392,17 @@ class StubCache {
// Support functions for IC stubs for callbacks.
MaybeObject* LoadCallbackProperty(RUNTIME_CALLING_CONVENTION);
MaybeObject* StoreCallbackProperty(RUNTIME_CALLING_CONVENTION);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty);
// Support functions for IC stubs for interceptors.
MaybeObject* LoadPropertyWithInterceptorOnly(RUNTIME_CALLING_CONVENTION);
MaybeObject* LoadPropertyWithInterceptorForLoad(RUNTIME_CALLING_CONVENTION);
MaybeObject* LoadPropertyWithInterceptorForCall(RUNTIME_CALLING_CONVENTION);
MaybeObject* StoreInterceptorProperty(RUNTIME_CALLING_CONVENTION);
MaybeObject* CallInterceptorProperty(RUNTIME_CALLING_CONVENTION);
MaybeObject* KeyedLoadPropertyWithInterceptor(RUNTIME_CALLING_CONVENTION);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor);
// The stub compiler compiles stubs for the stub cache.