Thread the current isolate through a few places, avoiding Isolate::Current().

This removes approx. 12k calls of Isolate::Current() in string-tagcloud.

Review URL: https://chromiumcodereview.appspot.com/9490004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10856 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2012-02-28 10:32:02 +00:00
parent 564a6f035a
commit 3df99e7eb7
9 changed files with 25 additions and 20 deletions

View File

@ -1055,7 +1055,7 @@ int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address,
ASSERT(*return_address <= ASSERT(*return_address <=
re_code->instruction_start() + re_code->instruction_size()); re_code->instruction_start() + re_code->instruction_size());
MaybeObject* result = Execution::HandleStackGuardInterrupt(); MaybeObject* result = Execution::HandleStackGuardInterrupt(isolate);
if (*code_handle != re_code) { // Return address no longer valid if (*code_handle != re_code) { // Return address no longer valid
int delta = code_handle->address() - re_code->address(); int delta = code_handle->address() - re_code->address();

View File

@ -872,8 +872,7 @@ void Execution::ProcessDebugMessages(bool debug_command_only) {
#endif #endif
MaybeObject* Execution::HandleStackGuardInterrupt() { MaybeObject* Execution::HandleStackGuardInterrupt(Isolate* isolate) {
Isolate* isolate = Isolate::Current();
StackGuard* stack_guard = isolate->stack_guard(); StackGuard* stack_guard = isolate->stack_guard();
if (stack_guard->IsGCRequest()) { if (stack_guard->IsGCRequest()) {

View File

@ -45,6 +45,10 @@ enum InterruptFlag {
GC_REQUEST = 1 << 6 GC_REQUEST = 1 << 6
}; };
class Isolate;
class Execution : public AllStatic { class Execution : public AllStatic {
public: public:
// Call a function, the caller supplies a receiver and an array // Call a function, the caller supplies a receiver and an array
@ -141,7 +145,8 @@ class Execution : public AllStatic {
// If the stack guard is triggered, but it is not an actual // If the stack guard is triggered, but it is not an actual
// stack overflow, then handle the interruption accordingly. // stack overflow, then handle the interruption accordingly.
MUST_USE_RESULT static MaybeObject* HandleStackGuardInterrupt(); MUST_USE_RESULT static MaybeObject* HandleStackGuardInterrupt(
Isolate* isolate);
// Get a function delegate (or undefined) for the given non-function // Get a function delegate (or undefined) for the given non-function
// object. Used for support calling objects as functions. // object. Used for support calling objects as functions.
@ -158,7 +163,6 @@ class Execution : public AllStatic {
class ExecutionAccess; class ExecutionAccess;
class Isolate;
// StackGuard contains the handling of the limits that are used to limit the // StackGuard contains the handling of the limits that are used to limit the

View File

@ -1085,7 +1085,7 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address,
ASSERT(*return_address <= ASSERT(*return_address <=
re_code->instruction_start() + re_code->instruction_size()); re_code->instruction_start() + re_code->instruction_size());
MaybeObject* result = Execution::HandleStackGuardInterrupt(); MaybeObject* result = Execution::HandleStackGuardInterrupt(isolate);
if (*code_handle != re_code) { // Return address no longer valid if (*code_handle != re_code) { // Return address no longer valid
int delta = code_handle->address() - re_code->address(); int delta = code_handle->address() - re_code->address();

View File

@ -175,7 +175,8 @@ Handle<Object> RegExpImpl::Exec(Handle<JSRegExp> regexp,
case JSRegExp::IRREGEXP: { case JSRegExp::IRREGEXP: {
Handle<Object> result = Handle<Object> result =
IrregexpExec(regexp, subject, index, last_match_info); IrregexpExec(regexp, subject, index, last_match_info);
ASSERT(!result.is_null() || Isolate::Current()->has_pending_exception()); ASSERT(!result.is_null() ||
regexp->GetIsolate()->has_pending_exception());
return result; return result;
} }
default: default:
@ -527,6 +528,7 @@ Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp,
Handle<String> subject, Handle<String> subject,
int previous_index, int previous_index,
Handle<JSArray> last_match_info) { Handle<JSArray> last_match_info) {
Isolate* isolate = jsregexp->GetIsolate();
ASSERT_EQ(jsregexp->TypeTag(), JSRegExp::IRREGEXP); ASSERT_EQ(jsregexp->TypeTag(), JSRegExp::IRREGEXP);
// Prepare space for the return values. // Prepare space for the return values.
@ -542,11 +544,11 @@ Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp,
int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject);
if (required_registers < 0) { if (required_registers < 0) {
// Compiling failed with an exception. // Compiling failed with an exception.
ASSERT(Isolate::Current()->has_pending_exception()); ASSERT(isolate->has_pending_exception());
return Handle<Object>::null(); return Handle<Object>::null();
} }
OffsetsVector registers(required_registers); OffsetsVector registers(required_registers, isolate);
IrregexpResult res = RegExpImpl::IrregexpExecOnce( IrregexpResult res = RegExpImpl::IrregexpExecOnce(
jsregexp, subject, previous_index, Vector<int>(registers.vector(), jsregexp, subject, previous_index, Vector<int>(registers.vector(),
@ -568,11 +570,11 @@ Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp,
return last_match_info; return last_match_info;
} }
if (res == RE_EXCEPTION) { if (res == RE_EXCEPTION) {
ASSERT(Isolate::Current()->has_pending_exception()); ASSERT(isolate->has_pending_exception());
return Handle<Object>::null(); return Handle<Object>::null();
} }
ASSERT(res == RE_FAILURE); ASSERT(res == RE_FAILURE);
return Isolate::Current()->factory()->null_value(); return isolate->factory()->null_value();
} }

View File

@ -1466,12 +1466,12 @@ class RegExpEngine: public AllStatic {
class OffsetsVector { class OffsetsVector {
public: public:
explicit inline OffsetsVector(int num_registers) inline OffsetsVector(int num_registers, Isolate* isolate)
: offsets_vector_length_(num_registers) { : offsets_vector_length_(num_registers) {
if (offsets_vector_length_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { if (offsets_vector_length_ > Isolate::kJSRegexpStaticOffsetsVectorSize) {
vector_ = NewArray<int>(offsets_vector_length_); vector_ = NewArray<int>(offsets_vector_length_);
} else { } else {
vector_ = Isolate::Current()->jsregexp_static_offsets_vector(); vector_ = isolate->jsregexp_static_offsets_vector();
} }
} }
inline ~OffsetsVector() { inline ~OffsetsVector() {

View File

@ -1056,7 +1056,7 @@ int RegExpMacroAssemblerMIPS::CheckStackGuardState(Address* return_address,
ASSERT(*return_address <= ASSERT(*return_address <=
re_code->instruction_start() + re_code->instruction_size()); re_code->instruction_start() + re_code->instruction_size());
MaybeObject* result = Execution::HandleStackGuardInterrupt(); MaybeObject* result = Execution::HandleStackGuardInterrupt(isolate);
if (*code_handle != re_code) { // Return address no longer valid. if (*code_handle != re_code) { // Return address no longer valid.
int delta = code_handle->address() - re_code->address(); int delta = code_handle->address() - re_code->address();

View File

@ -3763,7 +3763,7 @@ static RegExpImpl::IrregexpResult SearchRegExpNoCaptureMultiple(
int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject);
if (required_registers < 0) return RegExpImpl::RE_EXCEPTION; if (required_registers < 0) return RegExpImpl::RE_EXCEPTION;
OffsetsVector registers(required_registers); OffsetsVector registers(required_registers, isolate);
Vector<int32_t> register_vector(registers.vector(), registers.length()); Vector<int32_t> register_vector(registers.vector(), registers.length());
int subject_length = subject->length(); int subject_length = subject->length();
bool first = true; bool first = true;
@ -3836,7 +3836,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple(
int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject); int required_registers = RegExpImpl::IrregexpPrepare(regexp, subject);
if (required_registers < 0) return RegExpImpl::RE_EXCEPTION; if (required_registers < 0) return RegExpImpl::RE_EXCEPTION;
OffsetsVector registers(required_registers); OffsetsVector registers(required_registers, isolate);
Vector<int32_t> register_vector(registers.vector(), registers.length()); Vector<int32_t> register_vector(registers.vector(), registers.length());
RegExpImpl::IrregexpResult result = RegExpImpl::IrregexpResult result =
@ -3855,7 +3855,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple(
if (result == RegExpImpl::RE_SUCCESS) { if (result == RegExpImpl::RE_SUCCESS) {
// Need to keep a copy of the previous match for creating last_match_info // Need to keep a copy of the previous match for creating last_match_info
// at the end, so we have two vectors that we swap between. // at the end, so we have two vectors that we swap between.
OffsetsVector registers2(required_registers); OffsetsVector registers2(required_registers, isolate);
Vector<int> prev_register_vector(registers2.vector(), registers2.length()); Vector<int> prev_register_vector(registers2.vector(), registers2.length());
bool first = true; bool first = true;
do { do {
@ -9200,13 +9200,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) {
return isolate->StackOverflow(); return isolate->StackOverflow();
} }
return Execution::HandleStackGuardInterrupt(); return Execution::HandleStackGuardInterrupt(isolate);
} }
RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) {
ASSERT(args.length() == 0); ASSERT(args.length() == 0);
return Execution::HandleStackGuardInterrupt(); return Execution::HandleStackGuardInterrupt(isolate);
} }

View File

@ -1192,7 +1192,7 @@ int RegExpMacroAssemblerX64::CheckStackGuardState(Address* return_address,
ASSERT(*return_address <= ASSERT(*return_address <=
re_code->instruction_start() + re_code->instruction_size()); re_code->instruction_start() + re_code->instruction_size());
MaybeObject* result = Execution::HandleStackGuardInterrupt(); MaybeObject* result = Execution::HandleStackGuardInterrupt(isolate);
if (*code_handle != re_code) { // Return address no longer valid if (*code_handle != re_code) { // Return address no longer valid
intptr_t delta = code_handle->address() - re_code->address(); intptr_t delta = code_handle->address() - re_code->address();