Reviewers: Sven Panne,
Message:
Committed patchset #1 manually as r14819 (presubmit successful).
Description:
make isolate accessible from returnvalue
[email protected]
BUG=
Committed: https://code.google.com/p/v8/source/detail?r=14819
Please review this at https://codereview.chromium.org/16021010/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M include/v8.h
M src/arm/stub-cache-arm.cc
M src/ia32/stub-cache-ia32.cc
M src/x64/stub-cache-x64.cc
M test/cctest/test-api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
7dfc9189aa307198416f02c8f804c10d1653adbe..b5c780afc0150e444eb423d5ad5f13ebcba092b1
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2782,16 +2782,16 @@ class ReturnValue {
V8_INLINE(void Set(const Persistent<T>& handle));
V8_INLINE(void Set(const Handle<T> handle));
// Fast primitive setters
- V8_INLINE(void Set(Isolate* isolate, bool value));
- V8_INLINE(void Set(Isolate* isolate, double i));
- V8_INLINE(void Set(Isolate* isolate, int32_t i));
- V8_INLINE(void Set(Isolate* isolate, uint32_t i));
+ V8_INLINE(void Set(bool value));
+ V8_INLINE(void Set(double i));
+ V8_INLINE(void Set(int32_t i));
+ V8_INLINE(void Set(uint32_t i));
// Fast JS primitive setters
- V8_INLINE(void SetNull(Isolate* isolate));
- V8_INLINE(void SetUndefined(Isolate* isolate));
+ V8_INLINE(void SetNull());
+ V8_INLINE(void SetUndefined());
+ // Convenience getter for Isolate
+ V8_INLINE(Isolate* GetIsolate());
private:
- V8_INLINE(void SetTrue(Isolate* isolate));
- V8_INLINE(void SetFalse(Isolate* isolate));
internal::Object** value_;
};
@@ -2868,8 +2868,8 @@ class PropertyCallbackInfo {
static const int kThisIndex = 0;
static const int kHolderIndex = -1;
static const int kDataIndex = -2;
- static const int kIsolateIndex = -3;
- static const int kReturnValueIndex = -4;
+ static const int kReturnValueIndex = -3;
+ static const int kIsolateIndex = -4;
V8_INLINE(PropertyCallbackInfo(internal::Object** args))
: args_(args) { }
@@ -5694,61 +5694,58 @@ void ReturnValue<T>::Set(const Handle<T> handle) {
}
template<typename T>
-void ReturnValue<T>::Set(Isolate* isolate, double i) {
- Set(Number::New(isolate, i));
+void ReturnValue<T>::Set(double i) {
+ Set(Number::New(GetIsolate(), i));
}
template<typename T>
-void ReturnValue<T>::Set(Isolate* isolate, int32_t i) {
+void ReturnValue<T>::Set(int32_t i) {
typedef internal::Internals I;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
return;
}
- Set(Integer::New(i, isolate));
+ Set(Integer::New(i, GetIsolate()));
}
template<typename T>
-void ReturnValue<T>::Set(Isolate* isolate, uint32_t i) {
+void ReturnValue<T>::Set(uint32_t i) {
typedef internal::Internals I;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
return;
}
- Set(Integer::NewFromUnsigned(i, isolate));
+ Set(Integer::NewFromUnsigned(i, GetIsolate()));
}
template<typename T>
-void ReturnValue<T>::Set(Isolate* isolate, bool value) {
+void ReturnValue<T>::Set(bool value) {
+ typedef internal::Internals I;
+ int root_index;
if (value) {
- SetTrue(isolate);
+ root_index = I::kTrueValueRootIndex;
} else {
- SetFalse(isolate);
+ root_index = I::kFalseValueRootIndex;
}
+ *value_ = *I::GetRoot(GetIsolate(), root_index);
}
template<typename T>
-void ReturnValue<T>::SetTrue(Isolate* isolate) {
- typedef internal::Internals I;
- *value_ = *I::GetRoot(isolate, I::kTrueValueRootIndex);
-}
-
-template<typename T>
-void ReturnValue<T>::SetFalse(Isolate* isolate) {
+void ReturnValue<T>::SetNull() {
typedef internal::Internals I;
- *value_ = *I::GetRoot(isolate, I::kFalseValueRootIndex);
+ *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
}
template<typename T>
-void ReturnValue<T>::SetNull(Isolate* isolate) {
+void ReturnValue<T>::SetUndefined() {
typedef internal::Internals I;
- *value_ = *I::GetRoot(isolate, I::kNullValueRootIndex);
+ *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
}
template<typename T>
-void ReturnValue<T>::SetUndefined(Isolate* isolate) {
- typedef internal::Internals I;
- *value_ = *I::GetRoot(isolate, I::kUndefinedValueRootIndex);
+Isolate* ReturnValue<T>::GetIsolate() {
+ // Isolate is always the pointer below value_ on the stack.
+ return *reinterpret_cast<Isolate**>(&value_[-1]);
}
Index: src/arm/stub-cache-arm.cc
diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
index
1ede12ce69b7ae313d0a6f90ebf03d9607aa4853..912caed108290700c72204f38f7cd1b0be7dfa54
100644
--- a/src/arm/stub-cache-arm.cc
+++ b/src/arm/stub-cache-arm.cc
@@ -1433,9 +1433,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ Move(scratch3(), Handle<Object>(callback->data(), isolate()));
}
__ Push(reg, scratch3());
- __ mov(scratch3(),
+ __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex);
+ __ mov(scratch4(),
Operand(ExternalReference::isolate_address(isolate())));
- __ LoadRoot(scratch4(), Heap::kUndefinedValueRootIndex);
__ Push(scratch3(), scratch4(), name());
__ mov(r0, sp); // r0 = Handle<Name>
@@ -1462,7 +1462,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ CallApiFunctionAndReturn(ref,
kStackUnwindSpace,
returns_handle,
- 3);
+ 4);
}
Index: src/ia32/stub-cache-ia32.cc
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index
e1db7cdc8457a9f1207cb592155117735456374a..7cb7811e22685547c9c90f6b75725b0e90b0f6bf
100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -1386,8 +1386,8 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
} else {
__ push(Immediate(Handle<Object>(callback->data(), isolate())));
}
- __ push(Immediate(reinterpret_cast<int>(isolate())));
__ push(Immediate(isolate()->factory()->undefined_value())); //
ReturnValue
+ __ push(Immediate(reinterpret_cast<int>(isolate())));
// Save a pointer to where we pushed the arguments pointer. This will be
// passed as the const ExecutableAccessorInfo& to the C++ callback.
@@ -1420,7 +1420,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ CallApiFunctionAndReturn(getter_address,
kStackSpace,
returns_handle,
- 4);
+ 5);
}
Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index
36fcb84de2e4929bb5ffa2f0e2fb8b4e95df5a5b..c1cab8f2a2cf287fea538af4337fa5709ac2158c
100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -1303,9 +1303,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
} else {
__ Push(Handle<Object>(callback->data(), isolate()));
}
- __ PushAddress(ExternalReference::isolate_address(isolate()));
__ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
__ push(kScratchRegister); // return value
+ __ PushAddress(ExternalReference::isolate_address(isolate()));
__ push(name()); // name
// Save a pointer to where we pushed the arguments pointer. This will be
// passed as the const ExecutableAccessorInfo& to the C++ callback.
@@ -1350,7 +1350,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ CallApiFunctionAndReturn(getter_address,
kStackSpace,
returns_handle,
- 3);
+ 4);
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
2e5cce6b2f1e25c497813f35e5b3706e85ef2246..9097039b4c5762dde28bab7106996cb2fca38b2c
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -810,7 +810,8 @@ template<typename T>
static void CheckReturnValue(const T& t) {
v8::ReturnValue<v8::Value> rv = t.GetReturnValue();
i::Object** o = *reinterpret_cast<i::Object***>(&rv);
- CHECK_EQ(t.GetIsolate(), v8::Isolate::GetCurrent());
+ CHECK_EQ(v8::Isolate::GetCurrent(), t.GetIsolate());
+ CHECK_EQ(t.GetIsolate(), rv.GetIsolate());
CHECK((*o)->IsTheHole() || (*o)->IsUndefined());
}
@@ -927,7 +928,7 @@ static void TestFunctionTemplateInitializer(Handler
handler,
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
- fun_templ->SetCallHandler(handler);
+ fun_templ->SetCallHandler(handler_2);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("obj"), fun);
Local<Script> script = v8_compile("obj()");
@@ -1037,34 +1038,39 @@ static bool fast_return_value_void_is_null = false;
template<>
void FastReturnValueCallback<int32_t>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(info.GetIsolate(), kFastReturnValueInt32);
+ CheckReturnValue(info);
+ info.GetReturnValue().Set(kFastReturnValueInt32);
}
template<>
void FastReturnValueCallback<uint32_t>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(info.GetIsolate(), kFastReturnValueUint32);
+ CheckReturnValue(info);
+ info.GetReturnValue().Set(kFastReturnValueUint32);
}
template<>
void FastReturnValueCallback<double>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(info.GetIsolate(), kFastReturnValueDouble);
+ CheckReturnValue(info);
+ info.GetReturnValue().Set(kFastReturnValueDouble);
}
template<>
void FastReturnValueCallback<bool>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(info.GetIsolate(), fast_return_value_bool);
+ CheckReturnValue(info);
+ info.GetReturnValue().Set(fast_return_value_bool);
}
template<>
void FastReturnValueCallback<void>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
+ CheckReturnValue(info);
if (fast_return_value_void_is_null) {
- info.GetReturnValue().SetNull(info.GetIsolate());
+ info.GetReturnValue().SetNull();
} else {
- info.GetReturnValue().SetUndefined(info.GetIsolate());
+ info.GetReturnValue().SetUndefined();
}
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.