Revision: 5463
Author: [email protected]
Date: Wed Sep 15 08:20:49 2010
Log: Pass current isolate address to the regexp native functions. Immediate
effect of this change is a modest speed up(<4%)on a few tests but we will
need isolate pointer to pass it directly into Handle constructors and
Factory calls for further RegExp optimizations.
BUG=
TEST=
Review URL: http://codereview.chromium.org/3357023
http://code.google.com/p/v8/source/detail?r=5463
Modified:
/branches/experimental/isolates/src/api.cc
/branches/experimental/isolates/src/arm/code-stubs-arm.cc
/branches/experimental/isolates/src/arm/macro-assembler-arm.cc
/branches/experimental/isolates/src/arm/macro-assembler-arm.h
/branches/experimental/isolates/src/arm/regexp-macro-assembler-arm.cc
/branches/experimental/isolates/src/arm/regexp-macro-assembler-arm.h
/branches/experimental/isolates/src/arm/simulator-arm.h
/branches/experimental/isolates/src/ia32/macro-assembler-ia32.cc
/branches/experimental/isolates/src/ia32/regexp-macro-assembler-ia32.cc
/branches/experimental/isolates/src/ia32/regexp-macro-assembler-ia32.h
/branches/experimental/isolates/src/ia32/simulator-ia32.h
/branches/experimental/isolates/src/interpreter-irregexp.cc
/branches/experimental/isolates/src/jsregexp.cc
/branches/experimental/isolates/src/objects-inl.h
/branches/experimental/isolates/src/objects.h
/branches/experimental/isolates/src/regexp-macro-assembler.cc
/branches/experimental/isolates/src/regexp-macro-assembler.h
/branches/experimental/isolates/src/v8.cc
/branches/experimental/isolates/src/v8.h
/branches/experimental/isolates/src/x64/macro-assembler-x64.cc
/branches/experimental/isolates/src/x64/regexp-macro-assembler-x64.cc
/branches/experimental/isolates/src/x64/regexp-macro-assembler-x64.h
/branches/experimental/isolates/src/x64/simulator-x64.h
/branches/experimental/isolates/test/cctest/test-regexp.cc
=======================================
--- /branches/experimental/isolates/src/api.cc Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/api.cc Wed Sep 15 08:20:49 2010
@@ -2575,7 +2575,7 @@
do {
// Generate a random 32-bit hash value but limit range to fit
// within a smi.
- hash_value = i::V8::Random() & i::Smi::kMaxValue;
+ hash_value = i::V8::Random(self->GetIsolate()) & i::Smi::kMaxValue;
attempts++;
} while (hash_value == 0 && attempts < 30);
hash_value = hash_value != 0 ? hash_value : 1; // never return 0
=======================================
--- /branches/experimental/isolates/src/arm/code-stubs-arm.cc Thu Sep 9
17:53:48 2010
+++ /branches/experimental/isolates/src/arm/code-stubs-arm.cc Wed Sep 15
08:20:49 2010
@@ -3312,7 +3312,7 @@
// Locate the code entry and call it.
__ add(r7, r7, Operand(Code::kHeaderSize - kHeapObjectTag));
- __ CallCFunction(r7, kRegExpExecuteArguments);
+ __ CallCFunction(r7, r9, kRegExpExecuteArguments);
__ pop(lr);
// r0: result
=======================================
--- /branches/experimental/isolates/src/arm/macro-assembler-arm.cc Thu Sep
9 17:53:48 2010
+++ /branches/experimental/isolates/src/arm/macro-assembler-arm.cc Wed Sep
15 08:20:49 2010
@@ -1875,11 +1875,17 @@
b(ne, failure);
}
+static const int kRegisterPassedArguments = 4;
void MacroAssembler::PrepareCallCFunction(int num_arguments, Register
scratch) {
int frame_alignment = ActivationFrameAlignment();
+
+ // Reserve space for Isolate address which is always passed as last
parameter
+ num_arguments += 1;
+
// Up to four simple arguments are passed in registers r0..r3.
- int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments -
4;
+ int stack_passed_arguments = (num_arguments <=
kRegisterPassedArguments) ?
+ 0 : num_arguments -
kRegisterPassedArguments;
if (frame_alignment > kPointerSize) {
// Make stack end at alignment and make room for num_arguments - 4
words
// and the original value of sp.
@@ -1896,12 +1902,37 @@
void MacroAssembler::CallCFunction(ExternalReference function,
int num_arguments) {
- mov(ip, Operand(function));
- CallCFunction(ip, num_arguments);
+ CallCFunctionHelper(no_reg, function, ip, num_arguments);
}
-
-void MacroAssembler::CallCFunction(Register function, int num_arguments) {
+void MacroAssembler::CallCFunction(Register function,
+ Register scratch,
+ int num_arguments) {
+ CallCFunctionHelper(function,
+ ExternalReference::the_hole_value_location(),
+ scratch,
+ num_arguments);
+
+}
+
+
+void MacroAssembler::CallCFunctionHelper(Register function,
+ ExternalReference
function_reference,
+ Register scratch,
+ int num_arguments) {
+ // Push Isolate address as the last argument.
+ if (num_arguments < kRegisterPassedArguments) {
+ Register arg_to_reg[] = {r0, r1, r2, r3};
+ Register r = arg_to_reg[num_arguments];
+ mov(r, Operand(ExternalReference::isolate_address()));
+ } else {
+ int stack_passed_arguments = num_arguments - kRegisterPassedArguments;
+ // Push Isolate address on the stack after the arguments.
+ mov(scratch, Operand(ExternalReference::isolate_address()));
+ str(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize));
+ }
+ num_arguments += 1;
+
// Make sure that the stack is aligned before calling a C function unless
// running in the simulator. The simulator has its own alignment check
which
// provides more information.
@@ -1925,8 +1956,13 @@
// Just call directly. The function called cannot cause a GC, or
// allow preemption, so the return address in the link register
// stays correct.
+ if (function.is(no_reg)) {
+ mov(scratch, Operand(function_reference));
+ function = scratch;
+ }
Call(function);
- int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments -
4;
+ int stack_passed_arguments = (num_arguments <=
kRegisterPassedArguments) ?
+ 0 : num_arguments -
kRegisterPassedArguments;
if (OS::ActivationFrameAlignment() > kPointerSize) {
ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize));
} else {
=======================================
--- /branches/experimental/isolates/src/arm/macro-assembler-arm.h Thu Sep
9 17:53:48 2010
+++ /branches/experimental/isolates/src/arm/macro-assembler-arm.h Wed Sep
15 08:20:49 2010
@@ -572,7 +572,7 @@
// return address (unless this is somehow accounted for by the called
// function).
void CallCFunction(ExternalReference function, int num_arguments);
- void CallCFunction(Register function, int num_arguments);
+ void CallCFunction(Register function, Register scratch, int
num_arguments);
// Jump to a runtime routine.
void JumpToExternalReference(const ExternalReference& builtin);
@@ -670,6 +670,11 @@
private:
+ void CallCFunctionHelper(Register function,
+ ExternalReference function_reference,
+ Register scratch,
+ int num_arguments);
+
void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al);
=======================================
--- /branches/experimental/isolates/src/arm/regexp-macro-assembler-arm.cc
Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/arm/regexp-macro-assembler-arm.cc
Wed Sep 15 08:20:49 2010
@@ -60,6 +60,7 @@
*
* Each call to a public method should retain this convention.
* The stack will have the following structure:
+ * - Isolate* isolate (Address of the current isolate)
* - direct_call (if 1, direct call from JavaScript code, if
0 call
* through the runtime system)
* - stack_area_base (High end of the memory area to use as
@@ -992,8 +993,10 @@
int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address,
Code* re_code,
Address re_frame) {
- if (Isolate::Current()->stack_guard()->IsStackOverflow()) {
- Isolate::Current()->StackOverflow();
+ Isolate* isolate = frame_entry<Isolate*>(re_frame, kIsolate);
+ ASSERT(isolate == Isolate::Current());
+ if (isolate->stack_guard()->IsStackOverflow()) {
+ isolate->StackOverflow();
return EXCEPTION;
}
=======================================
--- /branches/experimental/isolates/src/arm/regexp-macro-assembler-arm.h
Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/arm/regexp-macro-assembler-arm.h
Wed Sep 15 08:20:49 2010
@@ -125,6 +125,7 @@
static const int kRegisterOutput = kReturnAddress + kPointerSize;
static const int kStackHighEnd = kRegisterOutput + kPointerSize;
static const int kDirectCall = kStackHighEnd + kPointerSize;
+ static const int kIsolate = kDirectCall + kPointerSize;
// Below the frame pointer.
// Register parameters stored by setup code.
=======================================
--- /branches/experimental/isolates/src/arm/simulator-arm.h Mon Aug 9
14:00:56 2010
+++ /branches/experimental/isolates/src/arm/simulator-arm.h Wed Sep 15
08:20:49 2010
@@ -62,9 +62,9 @@
// Call the generated regexp code directly. The entry function pointer
should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
- entry(p0, p1, p2, p3, p4, p5, p6)
+// expect nine int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \
+ entry(p0, p1, p2, p3, p4, p5, p6, p7)
#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
reinterpret_cast<TryCatch*>(try_catch_address)
@@ -79,9 +79,9 @@
assembler::arm::Simulator::current(Isolate::Current())-> \
Call(FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4))
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5,
p6) \
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6,
p7) \
assembler::arm::Simulator::current(Isolate::Current())->Call(
\
- FUNCTION_ADDR(entry), 7, p0, p1, p2, p3, p4, p5, p6)
+ FUNCTION_ADDR(entry), 8, p0, p1, p2, p3, p4, p5, p6, p7)
#define
TRY_CATCH_FROM_ADDRESS(try_catch_address) \
try_catch_address ==
NULL ? \
=======================================
--- /branches/experimental/isolates/src/ia32/macro-assembler-ia32.cc Thu
Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/ia32/macro-assembler-ia32.cc Wed
Sep 15 08:20:49 2010
@@ -1604,6 +1604,9 @@
void MacroAssembler::PrepareCallCFunction(int num_arguments, Register
scratch) {
+ // Reserve space for Isolate address which is always passed as last
parameter
+ num_arguments += 1;
+
int frameAlignment = OS::ActivationFrameAlignment();
if (frameAlignment != 0) {
// Make stack end at alignment and make room for num_arguments words
@@ -1629,6 +1632,11 @@
void MacroAssembler::CallCFunction(Register function,
int num_arguments) {
+ // Pass current isolate address as additional parameter.
+ mov(Operand(esp, num_arguments * kPointerSize),
+ Immediate(ExternalReference::isolate_address()));
+ num_arguments += 1;
+
// Check stack alignment.
if (FLAG_debug_code) {
CheckStackAlignment();
=======================================
--- /branches/experimental/isolates/src/ia32/regexp-macro-assembler-ia32.cc
Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/ia32/regexp-macro-assembler-ia32.cc
Wed Sep 15 08:20:49 2010
@@ -56,6 +56,7 @@
*
* Each call to a public method should retain this convention.
* The stack will have the following structure:
+ * - Isolate* isolate (Address of the current isolate)
* - direct_call (if 1, direct call from JavaScript code,
if 0
* call through the runtime system)
* - stack_area_base (High end of the memory area to use as
@@ -1031,7 +1032,8 @@
int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address,
Code* re_code,
Address re_frame) {
- Isolate* isolate = Isolate::Current();
+ Isolate* isolate = frame_entry<Isolate*>(re_frame, kIsolate);
+ ASSERT(isolate == Isolate::Current());
if (isolate->stack_guard()->IsStackOverflow()) {
isolate->StackOverflow();
return EXCEPTION;
=======================================
--- /branches/experimental/isolates/src/ia32/regexp-macro-assembler-ia32.h
Tue May 11 00:29:10 2010
+++ /branches/experimental/isolates/src/ia32/regexp-macro-assembler-ia32.h
Wed Sep 15 08:20:49 2010
@@ -125,6 +125,7 @@
static const int kRegisterOutput = kInputEnd + kPointerSize;
static const int kStackHighEnd = kRegisterOutput + kPointerSize;
static const int kDirectCall = kStackHighEnd + kPointerSize;
+ static const int kIsolate = kDirectCall + kPointerSize;
// Below the frame pointer - local stack variables.
// When adding local variables remember to push space for them in
// the frame in GetCode.
=======================================
--- /branches/experimental/isolates/src/ia32/simulator-ia32.h Tue Jan 26
03:08:42 2010
+++ /branches/experimental/isolates/src/ia32/simulator-ia32.h Wed Sep 15
08:20:49 2010
@@ -52,9 +52,9 @@
};
// Call the generated regexp code directly. The entry function pointer
should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
- entry(p0, p1, p2, p3, p4, p5, p6)
+// expect nine int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \
+ entry(p0, p1, p2, p3, p4, p5, p6, p7)
#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
reinterpret_cast<TryCatch*>(try_catch_address)
=======================================
--- /branches/experimental/isolates/src/interpreter-irregexp.cc Wed Jun 30
11:08:29 2010
+++ /branches/experimental/isolates/src/interpreter-irregexp.cc Wed Sep 15
08:20:49 2010
@@ -163,10 +163,9 @@
}
~BacktrackStack() {
- Isolate* isolate = Isolate::Current();
- if (isolate->irregexp_interpreter_backtrack_stack_cache() == NULL) {
+ if (isolate_->irregexp_interpreter_backtrack_stack_cache() == NULL) {
// The cache is empty. Keep this backtrack stack around.
- isolate->set_irregexp_interpreter_backtrack_stack_cache(data_);
+ isolate_->set_irregexp_interpreter_backtrack_stack_cache(data_);
} else {
// A backtrack stack was already cached, just release this one.
DeleteArray(data_);
=======================================
--- /branches/experimental/isolates/src/jsregexp.cc Wed Sep 1 10:01:38 2010
+++ /branches/experimental/isolates/src/jsregexp.cc Wed Sep 15 08:20:49 2010
@@ -60,7 +60,6 @@
namespace v8 {
namespace internal {
-
Handle<Object> RegExpImpl::CreateRegExpLiteral(Handle<JSFunction>
constructor,
Handle<String> pattern,
Handle<String> flags,
@@ -99,7 +98,7 @@
SetElement(array, 0, pattern);
SetElement(array, 1, error_text);
Handle<Object> regexp_err = Factory::NewSyntaxError(message, array);
- Isolate::Current()->Throw(*regexp_err);
+ re->GetIsolate()->Throw(*regexp_err);
}
@@ -110,7 +109,7 @@
Handle<String> pattern,
Handle<String> flag_str) {
JSRegExp::Flags flags = RegExpFlagsFromString(flag_str);
- CompilationCache* compilation_cache =
Isolate::Current()->compilation_cache();
+ CompilationCache* compilation_cache =
re->GetIsolate()->compilation_cache();
Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern,
flags);
bool in_cache = !cached.is_null();
LOG(RegExpCompileEvent(re, in_cache));
@@ -209,7 +208,7 @@
Handle<String> subject,
int index,
Handle<JSArray> last_match_info) {
- RuntimeState* runtime_state = Isolate::Current()->runtime_state();
+ RuntimeState* runtime_state = re->GetIsolate()->runtime_state();
Handle<String>
needle(String::cast(re->DataAt(JSRegExp::kAtomPatternIndex)));
@@ -255,7 +254,7 @@
if (entry->IsJSObject()) {
// If it's a JSObject, a previous compilation failed and threw this
object.
// Re-throw the object without trying again.
- Isolate::Current()->Throw(entry);
+ re->GetIsolate()->Throw(entry);
return false;
}
ASSERT(entry->IsTheHole());
@@ -293,7 +292,7 @@
Factory::NewStringFromUtf8(CStrVector(result.error_message)));
Handle<Object> regexp_err =
Factory::NewSyntaxError("malformed_regexp", array);
- Isolate::Current()->Throw(*regexp_err);
+ re->GetIsolate()->Throw(*regexp_err);
re->SetDataAt(JSRegExp::code_index(is_ascii), *regexp_err);
return false;
}
@@ -409,7 +408,8 @@
subject,
output.start(),
output.length(),
- index);
+ index,
+ regexp->GetIsolate());
if (res != NativeRegExpMacroAssembler::RETRY) {
ASSERT(res != NativeRegExpMacroAssembler::EXCEPTION ||
Isolate::Current()->has_pending_exception());
=======================================
--- /branches/experimental/isolates/src/objects-inl.h Fri Sep 10 11:52:02
2010
+++ /branches/experimental/isolates/src/objects-inl.h Wed Sep 15 08:20:49
2010
@@ -1074,6 +1074,13 @@
ASSERT(HEAP->is_safe_to_read_maps());
return map()->heap();
}
+
+
+Isolate* HeapObject::GetIsolate() {
+ Isolate* i = GetHeap()->isolate();
+ ASSERT(i == Isolate::Current());
+ return i;
+}
Map* HeapObject::map() {
=======================================
--- /branches/experimental/isolates/src/objects.h Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/objects.h Wed Sep 15 08:20:49 2010
@@ -1010,6 +1010,10 @@
// The Heap the object was allocated in. Used also to access Isolate.
// This method can not be used during GC, it ASSERTs this.
inline Heap* GetHeap();
+ // Convenience method to get current isolate. This method can be
+ // accessed only when its result is the same as
+ // Isolate::Current(), it ASSERTs this. See also comment for GetHeap.
+ inline Isolate* GetIsolate();
// Converts an address to a HeapObject pointer.
static inline HeapObject* FromAddress(Address address);
=======================================
--- /branches/experimental/isolates/src/regexp-macro-assembler.cc Thu Jul
15 20:09:25 2010
+++ /branches/experimental/isolates/src/regexp-macro-assembler.cc Wed Sep
15 08:20:49 2010
@@ -105,7 +105,8 @@
Handle<String> subject,
int* offsets_vector,
int offsets_vector_length,
- int previous_index) {
+ int previous_index,
+ Isolate* isolate) {
ASSERT(subject->IsFlat());
ASSERT(previous_index >= 0);
@@ -142,7 +143,8 @@
start_offset,
input_start,
input_end,
- offsets_vector);
+ offsets_vector,
+ isolate);
return res;
}
@@ -153,10 +155,11 @@
int start_offset,
const byte* input_start,
const byte* input_end,
- int* output) {
- Isolate* isolate = Isolate::Current();
+ int* output,
+ Isolate* isolate) {
+ ASSERT(isolate == Isolate::Current());
typedef int (*matcher)(String*, int, const byte*,
- const byte*, int*, Address, int);
+ const byte*, int*, Address, int, Isolate*);
matcher matcher_func = FUNCTION_CAST<matcher>(code->entry());
// Ensure that the minimum stack has been allocated.
@@ -171,7 +174,8 @@
input_end,
output,
stack_base,
- direct_call);
+ direct_call,
+ isolate);
ASSERT(result <= SUCCESS);
ASSERT(result >= RETRY);
@@ -210,9 +214,11 @@
int NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16(
Address byte_offset1,
Address byte_offset2,
- size_t byte_length) {
+ size_t byte_length,
+ Isolate* isolate) {
+ ASSERT(isolate == Isolate::Current());
unibrow::Mapping<unibrow::Ecma262Canonicalize>* canonicalize =
- Isolate::Current()->regexp_macro_assembler_canonicalize();
+ isolate->regexp_macro_assembler_canonicalize();
// This function is not allowed to cause a garbage collection.
// A GC might move the calling generated code and invalidate the
// return address on the stack.
@@ -241,8 +247,10 @@
Address NativeRegExpMacroAssembler::GrowStack(Address stack_pointer,
- Address* stack_base) {
- RegExpStack* regexp_stack = Isolate::Current()->regexp_stack();
+ Address* stack_base,
+ Isolate* isolate) {
+ ASSERT(isolate == Isolate::Current());
+ RegExpStack* regexp_stack = isolate->regexp_stack();
size_t size = regexp_stack->stack_capacity();
Address old_stack_base = regexp_stack->stack_base();
ASSERT(old_stack_base == *stack_base);
=======================================
--- /branches/experimental/isolates/src/regexp-macro-assembler.h Thu Sep 9
17:53:48 2010
+++ /branches/experimental/isolates/src/regexp-macro-assembler.h Wed Sep 15
08:20:49 2010
@@ -189,20 +189,23 @@
Handle<String> subject,
int* offsets_vector,
int offsets_vector_length,
- int previous_index);
+ int previous_index,
+ Isolate* isolate);
// Compares two-byte strings case insensitively.
// Called from generated RegExp code.
static int CaseInsensitiveCompareUC16(Address byte_offset1,
Address byte_offset2,
- size_t byte_length);
+ size_t byte_length,
+ Isolate* isolate);
// Called from RegExp if the backtrack stack limit is hit.
// Tries to expand the stack. Returns the new stack-pointer if
// successful, and updates the stack_top address, or returns 0 if unable
// to grow the stack.
// This function must not trigger a garbage collection.
- static Address GrowStack(Address stack_pointer, Address* stack_top);
+ static Address GrowStack(Address stack_pointer, Address* stack_top,
+ Isolate* isolate);
static const byte* StringCharacterPosition(String* subject, int
start_index);
@@ -220,7 +223,8 @@
int start_offset,
const byte* input_start,
const byte* input_end,
- int* output);
+ int* output,
+ Isolate* isolate);
};
#endif // V8_INTERPRETED_REGEXP
=======================================
--- /branches/experimental/isolates/src/v8.cc Mon Aug 2 17:41:48 2010
+++ /branches/experimental/isolates/src/v8.cc Wed Sep 15 08:20:49 2010
@@ -103,7 +103,9 @@
}
-uint32_t V8::Random() {
+uint32_t V8::Random(Isolate* isolate) {
+ ASSERT(isolate == Isolate::Current());
+ // TODO(isolates): move lo and hi to isolate
// Random number generator using George Marsaglia's MWC algorithm.
static uint32_t hi = 0;
static uint32_t lo = 0;
@@ -140,7 +142,7 @@
Object* V8::FillHeapNumberWithRandom(Object* heap_number) {
- uint64_t random_bits = Random();
+ uint64_t random_bits = Random(Isolate::Current());
// Make a double* from address (heap_number + sizeof(double)).
double_int_union* r = reinterpret_cast<double_int_union*>(
reinterpret_cast<char*>(heap_number) +
=======================================
--- /branches/experimental/isolates/src/v8.h Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/v8.h Wed Sep 15 08:20:49 2010
@@ -93,7 +93,7 @@
bool take_snapshot = false);
// Random number generation support. Not cryptographically safe.
- static uint32_t Random();
+ static uint32_t Random(Isolate* isolate);
static Object* FillHeapNumberWithRandom(Object* heap_number);
// Idle notification directly from the API.
=======================================
--- /branches/experimental/isolates/src/x64/macro-assembler-x64.cc Thu Sep
9 17:53:48 2010
+++ /branches/experimental/isolates/src/x64/macro-assembler-x64.cc Wed Sep
15 08:20:49 2010
@@ -2797,6 +2797,11 @@
}
}
+#ifdef _WIN64
+static const int kRegisterPassedArguments = 4;
+#else
+static const int kRegisterPassedArguments = 6;
+#endif
int MacroAssembler::ArgumentStackSlotsForCFunctionCall(int num_arguments) {
// On Windows 64 stack slots are reserved by the caller for all arguments
@@ -2807,11 +2812,10 @@
// and the caller does not reserve stack slots for them.
ASSERT(num_arguments >= 0);
#ifdef _WIN64
- static const int kMinimumStackSlots = 4;
+ const int kMinimumStackSlots = kRegisterPassedArguments;
if (num_arguments < kMinimumStackSlots) return kMinimumStackSlots;
return num_arguments;
#else
- static const int kRegisterPassedArguments = 6;
if (num_arguments < kRegisterPassedArguments) return 0;
return num_arguments - kRegisterPassedArguments;
#endif
@@ -2822,6 +2826,10 @@
int frame_alignment = OS::ActivationFrameAlignment();
ASSERT(frame_alignment != 0);
ASSERT(num_arguments >= 0);
+
+ // Reserve space for Isolate address which is always passed as last
parameter
+ num_arguments += 1;
+
// Make stack end at alignment and allocate space for arguments and old
rsp.
movq(kScratchRegister, rsp);
ASSERT(IsPowerOf2(frame_alignment));
@@ -2841,6 +2849,26 @@
void MacroAssembler::CallCFunction(Register function, int num_arguments) {
+ // Pass current isolate address as additional parameter.
+ if (num_arguments < kRegisterPassedArguments) {
+#ifdef _WIN64
+ // First four arguments are passed in registers on Windows.
+ Register arg_to_reg[] = {rcx, rdx, r8, r9};
+#else
+ // First six arguments are passed in registers on other platforms.
+ Register arg_to_reg[] = {rdi, rsi, rdx, rcx, r8, r9};
+#endif
+ Register reg = arg_to_reg[num_arguments];
+ movq(reg, ExternalReference::isolate_address());
+ } else {
+ // Push Isolate pointer after all parameters.
+ int argument_slots_on_stack =
+ ArgumentStackSlotsForCFunctionCall(num_arguments);
+ movq(kScratchRegister, ExternalReference::isolate_address());
+ movq(Operand(rsp, argument_slots_on_stack * kPointerSize),
+ kScratchRegister);
+ }
+
// Check stack alignment.
if (FLAG_debug_code) {
CheckStackAlignment();
@@ -2849,6 +2877,7 @@
call(function);
ASSERT(OS::ActivationFrameAlignment() != 0);
ASSERT(num_arguments >= 0);
+ num_arguments += 1;
int argument_slots_on_stack =
ArgumentStackSlotsForCFunctionCall(num_arguments);
movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize));
=======================================
--- /branches/experimental/isolates/src/x64/regexp-macro-assembler-x64.cc
Thu Sep 9 17:53:48 2010
+++ /branches/experimental/isolates/src/x64/regexp-macro-assembler-x64.cc
Wed Sep 15 08:20:49 2010
@@ -68,6 +68,7 @@
*
* The stack will have the following content, in some order, indexable
from the
* frame pointer (see, e.g., kStackHighEnd):
+ * - Isolate* isolate (Address of the current isolate)
* - direct_call (if 1, direct call from JavaScript code, if 0
call
* through the runtime system)
* - stack_area_base (High end of the memory area to use as
@@ -1131,8 +1132,10 @@
int RegExpMacroAssemblerX64::CheckStackGuardState(Address* return_address,
Code* re_code,
Address re_frame) {
- if (Isolate::Current()->stack_guard()->IsStackOverflow()) {
- Isolate::Current()->StackOverflow();
+ Isolate* isolate = frame_entry<Isolate*>(re_frame, kIsolate);
+ ASSERT(isolate == Isolate::Current());
+ if (isolate->stack_guard()->IsStackOverflow()) {
+ isolate->StackOverflow();
return EXCEPTION;
}
=======================================
--- /branches/experimental/isolates/src/x64/regexp-macro-assembler-x64.h
Tue May 11 00:29:10 2010
+++ /branches/experimental/isolates/src/x64/regexp-macro-assembler-x64.h
Wed Sep 15 08:20:49 2010
@@ -141,6 +141,7 @@
static const int kStackHighEnd = kRegisterOutput + kPointerSize;
// DirectCall is passed as 32 bit int (values 0 or 1).
static const int kDirectCall = kStackHighEnd + kPointerSize;
+ static const int kIsolate = kDirectCall + kPointerSize;
#else
// In AMD64 ABI Calling Convention, the first six integer parameters
// are passed as registers, and caller must allocate space on the stack
@@ -152,6 +153,7 @@
static const int kRegisterOutput = kInputEnd - kPointerSize;
static const int kStackHighEnd = kRegisterOutput - kPointerSize;
static const int kDirectCall = kFrameAlign;
+ static const int kIsolate = kDirectCall + kPointerSize;
#endif
#ifdef _WIN64
=======================================
--- /branches/experimental/isolates/src/x64/simulator-x64.h Tue Jan 26
03:08:42 2010
+++ /branches/experimental/isolates/src/x64/simulator-x64.h Wed Sep 15
08:20:49 2010
@@ -53,9 +53,9 @@
};
// Call the generated regexp code directly. The entry function pointer
should
-// expect eight int/pointer sized arguments and return an int.
-#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6) \
- entry(p0, p1, p2, p3, p4, p5, p6)
+// expect nine int/pointer sized arguments and return an int.
+#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7) \
+ entry(p0, p1, p2, p3, p4, p5, p6, p7)
#define TRY_CATCH_FROM_ADDRESS(try_catch_address) \
reinterpret_cast<TryCatch*>(try_catch_address)
=======================================
--- /branches/experimental/isolates/test/cctest/test-regexp.cc Mon Aug 9
14:00:56 2010
+++ /branches/experimental/isolates/test/cctest/test-regexp.cc Wed Sep 15
08:20:49 2010
@@ -690,7 +690,8 @@
start_offset,
input_start,
input_end,
- captures);
+ captures,
+ Isolate::Current());
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev