Revision: 14819
Author: [email protected]
Date: Mon May 27 04:50:08 2013
Log: make isolate accessible from returnvalue
[email protected]
BUG=
Review URL: https://codereview.chromium.org/16021010
http://code.google.com/p/v8/source/detail?r=14819
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/arm/stub-cache-arm.cc
/branches/bleeding_edge/src/ia32/stub-cache-ia32.cc
/branches/bleeding_edge/src/x64/stub-cache-x64.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Thu May 23 03:01:42 2013
+++ /branches/bleeding_edge/include/v8.h Mon May 27 04:50:08 2013
@@ -2782,16 +2782,16 @@
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 @@
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 @@
}
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;
}
-}
-
-template<typename T>
-void ReturnValue<T>::SetTrue(Isolate* isolate) {
- typedef internal::Internals I;
- *value_ = *I::GetRoot(isolate, I::kTrueValueRootIndex);
+ *value_ = *I::GetRoot(GetIsolate(), root_index);
}
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]);
}
=======================================
--- /branches/bleeding_edge/src/arm/stub-cache-arm.cc Thu May 23 02:19:18
2013
+++ /branches/bleeding_edge/src/arm/stub-cache-arm.cc Mon May 27 04:50:08
2013
@@ -1433,9 +1433,9 @@
__ 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 @@
__ CallApiFunctionAndReturn(ref,
kStackUnwindSpace,
returns_handle,
- 3);
+ 4);
}
=======================================
--- /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Thu May 23 02:19:18
2013
+++ /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Mon May 27 04:50:08
2013
@@ -1386,8 +1386,8 @@
} else {
__ push(Immediate(Handle<Object>(callback->data(), isolate())));
}
+ __ push(Immediate(isolate()->factory()->undefined_value())); //
ReturnValue
__ push(Immediate(reinterpret_cast<int>(isolate())));
- __ push(Immediate(isolate()->factory()->undefined_value())); //
ReturnValue
// 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 @@
__ CallApiFunctionAndReturn(getter_address,
kStackSpace,
returns_handle,
- 4);
+ 5);
}
=======================================
--- /branches/bleeding_edge/src/x64/stub-cache-x64.cc Thu May 23 02:19:18
2013
+++ /branches/bleeding_edge/src/x64/stub-cache-x64.cc Mon May 27 04:50:08
2013
@@ -1303,9 +1303,9 @@
} 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 @@
__ CallApiFunctionAndReturn(getter_address,
kStackSpace,
returns_handle,
- 3);
+ 4);
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Fri May 24 02:32:10 2013
+++ /branches/bleeding_edge/test/cctest/test-api.cc Mon May 27 04:50:08 2013
@@ -810,7 +810,8 @@
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 @@
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 @@
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.