Version 3.19.15
Performance and stability improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@15120 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/ChangeLog b/ChangeLog
index 907760a..e6a2761 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-13: Version 3.19.15
+
+ Performance and stability improvements on all platforms.
+
+
2013-06-13: Version 3.19.14
Fixed crashes when calling new Array(a) with a single argument that
diff --git a/include/v8.h b/include/v8.h
index 6fcc332..d2a5322 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -123,7 +123,6 @@
class Int32;
class Integer;
class Isolate;
-class LocalContext;
class Number;
class NumberObject;
class Object;
@@ -162,8 +161,7 @@
class HeapObject;
class Isolate;
class Object;
-template<typename T>
-class CustomArguments;
+template<typename T> class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
}
@@ -365,21 +363,19 @@
#endif
private:
+ friend class Utils;
template<class F> friend class Persistent;
template<class F> friend class Local;
friend class Arguments;
template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo;
- friend class String;
- friend class Object;
+ template<class F> friend class internal::CustomArguments;
friend class AccessorInfo;
friend Handle<Primitive> Undefined(Isolate* isolate);
friend Handle<Primitive> Null(Isolate* isolate);
friend Handle<Boolean> True(Isolate* isolate);
friend Handle<Boolean> False(Isolate* isolate);
friend class Context;
- friend class InternalHandleHelper;
- friend class LocalContext;
friend class HandleScope;
#ifndef V8_USE_UNSAFE_HANDLES
@@ -454,6 +450,7 @@
#endif
private:
+ friend class Utils;
template<class F> friend class Persistent;
template<class F> friend class Handle;
friend class Arguments;
@@ -463,8 +460,7 @@
friend class Object;
friend class AccessorInfo;
friend class Context;
- friend class InternalHandleHelper;
- friend class LocalContext;
+ template<class F> friend class internal::CustomArguments;
friend class HandleScope;
V8_INLINE(static Local<T> New(Isolate* isolate, T* that));
@@ -511,11 +507,11 @@
* to be separately disposed.
*/
template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that))
- : val_(*New(isolate, that)) { }
+ : val_(New(isolate, *that)) { }
template <class S> V8_INLINE(Persistent(Isolate* isolate,
Persistent<S>& that)) // NOLINT
- : val_(*New(isolate, that)) { }
+ : val_(New(isolate, *that)) { }
#else
/**
@@ -594,15 +590,9 @@
}
#endif
+#ifdef V8_USE_UNSAFE_HANDLES
V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
-
- /**
- * Creates a new persistent handle for an existing local or persistent handle.
- */
- // TODO(dcarney): remove before cutover
V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that));
-#ifndef V8_USE_UNSAFE_HANDLES
- // TODO(dcarney): remove before cutover
V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that));
#endif
@@ -652,23 +642,17 @@
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback));
- // TODO(dcarney): deprecate
template<typename S, typename P>
- V8_INLINE(void MakeWeak(
+ V8_DEPRECATED(void MakeWeak(
Isolate* isolate,
P* parameters,
- typename WeakReferenceCallbacks<S, P>::Revivable callback)) {
- MakeWeak<S, P>(parameters, callback);
- }
+ typename WeakReferenceCallbacks<S, P>::Revivable callback));
- // TODO(dcarney): deprecate
template<typename P>
- V8_INLINE(void MakeWeak(
+ V8_DEPRECATED(void MakeWeak(
Isolate* isolate,
P* parameters,
- typename WeakReferenceCallbacks<T, P>::Revivable callback)) {
- MakeWeak<P>(parameters, callback);
- }
+ typename WeakReferenceCallbacks<T, P>::Revivable callback));
V8_INLINE(void ClearWeak());
@@ -779,11 +763,7 @@
#endif
// TODO(dcarney): remove before cutover
template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { }
- // TODO(dcarney): remove before cutover
- template <class S> V8_INLINE(Persistent(Persistent<S> that))
- : val_(*that) {
- TYPE_CHECK(T, S);
- }
+
// TODO(dcarney): remove before cutover
V8_INLINE(T* operator*() const) { return val_; }
@@ -794,16 +774,13 @@
#endif
private:
+ friend class Utils;
template<class F> friend class Handle;
template<class F> friend class Local;
+ template<class F> friend class Persistent;
template<class F> friend class ReturnValue;
- friend class ImplementationUtilities;
- friend class ObjectTemplate;
- friend class Context;
- friend class InternalHandleHelper;
- friend class LocalContext;
- V8_INLINE(static Persistent<T> New(Isolate* isolate, T* that));
+ V8_INLINE(static T* New(Isolate* isolate, T* that));
#ifndef V8_USE_UNSAFE_HANDLES
T* val_;
@@ -5510,6 +5487,7 @@
}
+#ifdef V8_USE_UNSAFE_HANDLES
template <class T>
Persistent<T> Persistent<T>::New(Handle<T> that) {
return New(Isolate::GetCurrent(), that.val_);
@@ -5521,20 +5499,20 @@
return New(Isolate::GetCurrent(), that.val_);
}
-#ifndef V8_USE_UNSAFE_HANDLES
template <class T>
Persistent<T> Persistent<T>::New(Isolate* isolate, Persistent<T> that) {
return New(Isolate::GetCurrent(), that.val_);
}
#endif
+
template <class T>
-Persistent<T> Persistent<T>::New(Isolate* isolate, T* that) {
- if (that == NULL) return Persistent<T>();
+T* Persistent<T>::New(Isolate* isolate, T* that) {
+ if (that == NULL) return NULL;
internal::Object** p = reinterpret_cast<internal::Object**>(that);
- return Persistent<T>(reinterpret_cast<T*>(
+ return reinterpret_cast<T*>(
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
- p)));
+ p));
}
@@ -5598,6 +5576,26 @@
template <class T>
+template <typename S, typename P>
+void Persistent<T>::MakeWeak(
+ Isolate* isolate,
+ P* parameters,
+ typename WeakReferenceCallbacks<S, P>::Revivable callback) {
+ MakeWeak<S, P>(parameters, callback);
+}
+
+
+template <class T>
+template<typename P>
+void Persistent<T>::MakeWeak(
+ Isolate* isolate,
+ P* parameters,
+ typename WeakReferenceCallbacks<T, P>::Revivable callback) {
+ MakeWeak<P>(parameters, callback);
+}
+
+
+template <class T>
void Persistent<T>::ClearWeak() {
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
}
diff --git a/src/api.cc b/src/api.cc
index 5491971..a7e0b28 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -552,8 +552,7 @@
if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
return v8::Handle<v8::Primitive>();
}
- return v8::Handle<Primitive>(ToApi<Primitive>(
- isolate->factory()->undefined_value()));
+ return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
}
@@ -562,8 +561,7 @@
if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
return v8::Handle<v8::Primitive>();
}
- return v8::Handle<Primitive>(
- ToApi<Primitive>(isolate->factory()->null_value()));
+ return ToApiHandle<Primitive>(isolate->factory()->null_value());
}
@@ -572,8 +570,7 @@
if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
return v8::Handle<Boolean>();
}
- return v8::Handle<Boolean>(
- ToApi<Boolean>(isolate->factory()->true_value()));
+ return ToApiHandle<Boolean>(isolate->factory()->true_value());
}
@@ -582,8 +579,7 @@
if (!EnsureInitializedForIsolate(isolate, "v8::False()")) {
return v8::Handle<Boolean>();
}
- return v8::Handle<Boolean>(
- ToApi<Boolean>(isolate->factory()->false_value()));
+ return ToApiHandle<Boolean>(isolate->factory()->false_value());
}
@@ -953,7 +949,7 @@
result = Utils::OpenHandle(*ObjectTemplate::New());
Utils::OpenHandle(this)->set_prototype_template(*result);
}
- return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result));
+ return ToApiHandle<ObjectTemplate>(result);
}
@@ -1048,8 +1044,7 @@
static Local<Operation> NewDescriptor(
Isolate* isolate,
const i::DeclaredAccessorDescriptorData& data,
- Data* previous_descriptor
- ) {
+ Data* previous_descriptor) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::DeclaredAccessorDescriptor> previous =
i::Handle<i::DeclaredAccessorDescriptor>();
@@ -1059,8 +1054,7 @@
}
i::Handle<i::DeclaredAccessorDescriptor> descriptor =
i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous);
- return Local<Operation>(
- reinterpret_cast<Operation*>(*Utils::ToLocal(descriptor)));
+ return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor);
}
@@ -1301,13 +1295,14 @@
|| EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
return Local<ObjectTemplate>();
ENTER_V8(isolate);
- if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) {
+ i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this);
+ if (handle->instance_template()->IsUndefined()) {
Local<ObjectTemplate> templ =
- ObjectTemplate::New(v8::Handle<FunctionTemplate>(this));
- Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ));
+ ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle));
+ handle->set_instance_template(*Utils::OpenHandle(*templ));
}
- i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast(
- Utils::OpenHandle(this)->instance_template()));
+ i::Handle<i::ObjectTemplateInfo> result(
+ i::ObjectTemplateInfo::cast(handle->instance_template()));
return Utils::ToLocal(result);
}
@@ -1905,7 +1900,7 @@
raw_result = *result;
}
i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
- return Local<Script>(ToApi<Script>(result));
+ return ToApiHandle<Script>(result);
}
@@ -1934,7 +1929,7 @@
isolate->factory()->NewFunctionFromSharedFunctionInfo(
function,
isolate->global_context());
- return Local<Script>(ToApi<Script>(result));
+ return ToApiHandle<Script>(result);
}
@@ -2777,7 +2772,7 @@
str = i::Execution::ToString(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
}
- return Local<String>(ToApi<String>(str));
+ return ToApiHandle<String>(str);
}
@@ -2797,7 +2792,7 @@
str = i::Execution::ToDetailString(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
}
- return Local<String>(ToApi<String>(str));
+ return ToApiHandle<String>(str);
}
@@ -2817,14 +2812,14 @@
val = i::Execution::ToObject(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
}
- return Local<v8::Object>(ToApi<Object>(val));
+ return ToApiHandle<Object>(val);
}
Local<Boolean> Value::ToBoolean() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsBoolean()) {
- return Local<Boolean>(ToApi<Boolean>(obj));
+ return ToApiHandle<Boolean>(obj);
} else {
i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
@@ -2834,7 +2829,7 @@
ENTER_V8(isolate);
i::Handle<i::Object> val =
isolate->factory()->ToBoolean(obj->BooleanValue());
- return Local<Boolean>(ToApi<Boolean>(val));
+ return ToApiHandle<Boolean>(val);
}
}
@@ -2855,7 +2850,7 @@
num = i::Execution::ToNumber(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
}
- return Local<Number>(ToApi<Number>(num));
+ return ToApiHandle<Number>(num);
}
@@ -2873,7 +2868,7 @@
num = i::Execution::ToInteger(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
}
- return Local<Integer>(ToApi<Integer>(num));
+ return ToApiHandle<Integer>(num);
}
@@ -3103,7 +3098,7 @@
num = i::Execution::ToInt32(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
}
- return Local<Int32>(ToApi<Int32>(num));
+ return ToApiHandle<Int32>(num);
}
@@ -3121,7 +3116,7 @@
num = i::Execution::ToUint32(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
}
- return Local<Uint32>(ToApi<Uint32>(num));
+ return ToApiHandle<Uint32>(num);
}
@@ -5363,7 +5358,7 @@
return env;
}
-
+#ifdef V8_USE_UNSAFE_HANDLES
Persistent<Context> v8::Context::New(
v8::ExtensionConfiguration* extensions,
v8::Handle<ObjectTemplate> global_template,
@@ -5380,6 +5375,7 @@
if (env.is_null()) return Persistent<Context>();
return Persistent<Context>::New(external_isolate, Utils::ToLocal(env));
}
+#endif
Local<Context> v8::Context::New(
@@ -6553,24 +6549,27 @@
UniqueId id) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
internal_isolate->global_handles()->SetObjectGroupId(
- reinterpret_cast<i::Object**>(*object), id);
+ Utils::OpenPersistent(object).location(),
+ id);
}
void Isolate::SetReferenceFromGroup(UniqueId id,
const Persistent<Value>& object) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
- internal_isolate->global_handles()
- ->SetReferenceFromGroup(id, reinterpret_cast<i::Object**>(*object));
+ internal_isolate->global_handles()->SetReferenceFromGroup(
+ id,
+ Utils::OpenPersistent(object).location());
}
void Isolate::SetReference(const Persistent<Object>& parent,
const Persistent<Value>& child) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Object** parent_location = Utils::OpenPersistent(parent).location();
internal_isolate->global_handles()->SetReference(
- i::Handle<i::HeapObject>::cast(Utils::OpenHandle(*parent)).location(),
- reinterpret_cast<i::Object**>(*child));
+ reinterpret_cast<i::HeapObject**>(parent_location),
+ Utils::OpenPersistent(child).location());
}
@@ -7175,12 +7174,12 @@
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
const i::CodeEntry* entry = node->entry();
if (!entry->has_name_prefix()) {
- return Handle<String>(ToApi<String>(
- isolate->factory()->InternalizeUtf8String(entry->name())));
+ return ToApiHandle<String>(
+ isolate->factory()->InternalizeUtf8String(entry->name()));
} else {
- return Handle<String>(ToApi<String>(isolate->factory()->NewConsString(
+ return ToApiHandle<String>(isolate->factory()->NewConsString(
isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
- isolate->factory()->InternalizeUtf8String(entry->name()))));
+ isolate->factory()->InternalizeUtf8String(entry->name())));
}
}
@@ -7189,8 +7188,8 @@
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
- return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
- node->entry()->resource_name())));
+ return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
+ node->entry()->resource_name()));
}
@@ -7281,8 +7280,8 @@
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
- return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
- profile->title())));
+ return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
+ profile->title()));
}
@@ -7450,12 +7449,12 @@
case i::HeapGraphEdge::kInternal:
case i::HeapGraphEdge::kProperty:
case i::HeapGraphEdge::kShortcut:
- return Handle<String>(ToApi<String>(
- isolate->factory()->InternalizeUtf8String(edge->name())));
+ return ToApiHandle<String>(
+ isolate->factory()->InternalizeUtf8String(edge->name()));
case i::HeapGraphEdge::kElement:
case i::HeapGraphEdge::kHidden:
- return Handle<Number>(ToApi<Number>(
- isolate->factory()->NewNumberFromInt(edge->index())));
+ return ToApiHandle<Number>(
+ isolate->factory()->NewNumberFromInt(edge->index()));
default: UNREACHABLE();
}
return v8::Undefined();
@@ -7494,8 +7493,8 @@
Handle<String> HeapGraphNode::GetName() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
- return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
- ToInternal(this)->name())));
+ return ToApiHandle<String>(
+ isolate->factory()->InternalizeUtf8String(ToInternal(this)->name()));
}
@@ -7532,9 +7531,9 @@
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue");
i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject();
- return v8::Handle<Value>(!object.is_null() ?
- ToApi<Value>(object) : ToApi<Value>(
- isolate->factory()->undefined_value()));
+ return !object.is_null() ?
+ ToApiHandle<Value>(object) :
+ ToApiHandle<Value>(isolate->factory()->undefined_value());
}
@@ -7573,8 +7572,8 @@
Handle<String> HeapSnapshot::GetTitle() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
- return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
- ToInternal(this)->title())));
+ return ToApiHandle<String>(
+ isolate->factory()->InternalizeUtf8String(ToInternal(this)->title()));
}
diff --git a/src/api.h b/src/api.h
index 3c141f7..3d1c69c 100644
--- a/src/api.h
+++ b/src/api.h
@@ -273,16 +273,34 @@
OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE)
#undef DECLARE_OPEN_HANDLE
+
+ template<class From, class To>
+ static inline Local<To> Convert(v8::internal::Handle<From> obj) {
+ ASSERT(obj.is_null() || !obj->IsTheHole());
+ return Local<To>(reinterpret_cast<To*>(obj.location()));
+ }
+
+ template <class T>
+ static inline v8::internal::Handle<v8::internal::Object> OpenPersistent(
+ const v8::Persistent<T>& persistent) {
+ return v8::internal::Handle<v8::internal::Object>(
+ reinterpret_cast<v8::internal::Object**>(persistent.val_));
+ }
+
+ template <class T>
+ static inline v8::internal::Handle<v8::internal::Object> OpenPersistent(
+ v8::Persistent<T>* persistent) {
+ return OpenPersistent(*persistent);
+ }
+
+ template <class From, class To>
+ static inline v8::internal::Handle<To> OpenHandle(v8::Local<From> handle) {
+ return OpenHandle(*handle);
+ }
};
template <class T>
-inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {
- return reinterpret_cast<T*>(obj.location());
-}
-
-
-template <class T>
v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom(
v8::HandleScope* scope) {
v8::internal::Handle<T> handle;
@@ -293,31 +311,31 @@
}
-class InternalHandleHelper {
- public:
- template<class From, class To>
- static inline Local<To> Convert(v8::internal::Handle<From> obj) {
- return Local<To>(reinterpret_cast<To*>(obj.location()));
- }
-};
+template <class T>
+inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {
+ return reinterpret_cast<T*>(obj.location());
+}
+
+template <class T>
+inline v8::Local<T> ToApiHandle(
+ v8::internal::Handle<v8::internal::Object> obj) {
+ return Utils::Convert<v8::internal::Object, T>(obj);
+}
// Implementations of ToLocal
#define MAKE_TO_LOCAL(Name, From, To) \
Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \
- ASSERT(obj.is_null() || !obj->IsTheHole()); \
- return InternalHandleHelper::Convert<v8::internal::From, v8::To>(obj); \
+ return Convert<v8::internal::From, v8::To>(obj); \
}
#define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \
Local<v8::TypedArray> Utils::ToLocal##TypedArray( \
v8::internal::Handle<v8::internal::JSTypedArray> obj) { \
- ASSERT(obj.is_null() || !obj->IsTheHole()); \
ASSERT(obj->type() == typeConst); \
- return InternalHandleHelper:: \
- Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \
+ return Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \
}
diff --git a/src/arguments.cc b/src/arguments.cc
index 091d0b9..b15ae7e 100644
--- a/src/arguments.cc
+++ b/src/arguments.cc
@@ -82,7 +82,7 @@
Object** handle = &this->end()[kReturnValueOffset];
// Nothing was set, return empty handle as per previous behaviour.
if ((*handle)->IsTheHole()) return v8::Handle<V>();
- return v8::Handle<V>(reinterpret_cast<V*>(handle));
+ return Utils::Convert<Object, V>(Handle<Object>(handle));
}
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index 39a4018..468fa77 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -2035,21 +2035,20 @@
__ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
__ b(&l_next);
- // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; }
+ // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
__ bind(&l_catch);
handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
+ __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw"
__ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter
__ push(r3); // iter
__ push(r0); // exception
- __ mov(r0, r3); // iter
- __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw"
- Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(throw_ic); // iter.throw in r0
__ jmp(&l_call);
- // try { received = yield result.value }
+ // try { received = %yield result }
+ // Shuffle the received result above a try handler and yield it without
+ // re-boxing.
__ bind(&l_try);
- EmitCreateIteratorResult(false); // pop and box to r0
+ __ pop(r0); // result
__ PushTryHandler(StackHandler::CATCH, expr->index());
const int handler_size = StackHandlerConstants::kSize;
__ push(r0); // result
@@ -2065,42 +2064,22 @@
__ bind(&l_resume); // received in r0
__ PopTryHandler();
- // receiver = iter; f = iter.next; arg = received;
+ // receiver = iter; f = 'next'; arg = received;
__ bind(&l_next);
+ __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next"
__ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter
__ push(r3); // iter
__ push(r0); // received
- __ mov(r0, r3); // iter
- __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next"
- Handle<Code> next_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(next_ic); // iter.next in r0
- // result = f.call(receiver, arg);
+ // result = receiver[f](arg);
__ bind(&l_call);
- Label l_call_runtime;
- __ JumpIfSmi(r0, &l_call_runtime);
- __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE);
- __ b(ne, &l_call_runtime);
- __ mov(r1, r0);
- ParameterCount count(1);
- __ InvokeFunction(r1, count, CALL_FUNCTION,
- NullCallWrapper(), CALL_AS_METHOD);
+ Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1);
+ CallIC(ic);
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
- __ jmp(&l_loop);
- __ bind(&l_call_runtime);
- __ push(r0);
- __ CallRuntime(Runtime::kCall, 3);
- // val = result.value; if (!result.done) goto l_try;
+ // if (!result.done) goto l_try;
__ bind(&l_loop);
- // result.value
__ push(r0); // save result
- __ LoadRoot(r2, Heap::kvalue_stringRootIndex); // "value"
- Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(value_ic); // result.value in r0
- __ pop(r1); // result
- __ push(r0); // result.value
- __ mov(r0, r1); // result
__ LoadRoot(r2, Heap::kdone_stringRootIndex); // "done"
Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize();
CallIC(done_ic); // result.done in r0
@@ -2110,7 +2089,10 @@
__ b(eq, &l_try);
// result.value
- __ pop(r0); // result.value
+ __ pop(r0); // result
+ __ LoadRoot(r2, Heap::kvalue_stringRootIndex); // "value"
+ Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
+ CallIC(value_ic); // result.value in r0
context()->DropAndPlug(2, r0); // drop iter and g
break;
}
diff --git a/src/assert-scope.h b/src/assert-scope.h
index e2ec542..13adbd0 100644
--- a/src/assert-scope.h
+++ b/src/assert-scope.h
@@ -79,7 +79,11 @@
protected:
PerThreadAssertScopeBase() {
- data_ = AssertData();
+ data_ = GetAssertData();
+ if (data_ == NULL) {
+ data_ = new PerThreadAssertData();
+ SetThreadLocalData(data_);
+ }
data_->increment_level();
}
@@ -89,22 +93,22 @@
ASSERT(data_->get(static_cast<PerThreadAssertType>(i)));
}
delete data_;
- Thread::SetThreadLocal(thread_local_key, NULL);
+ SetThreadLocalData(NULL);
}
- static PerThreadAssertData* AssertData() {
- PerThreadAssertData* data = reinterpret_cast<PerThreadAssertData*>(
- Thread::GetThreadLocal(thread_local_key));
- if (data == NULL) {
- data = new PerThreadAssertData();
- Thread::SetThreadLocal(thread_local_key, data);
- }
- return data;
+ static PerThreadAssertData* GetAssertData() {
+ return reinterpret_cast<PerThreadAssertData*>(
+ Thread::GetThreadLocal(thread_local_key));
}
static Thread::LocalStorageKey thread_local_key;
PerThreadAssertData* data_;
friend class Isolate;
+
+ private:
+ static void SetThreadLocalData(PerThreadAssertData* data) {
+ Thread::SetThreadLocal(thread_local_key, data);
+ }
#endif // DEBUG
};
@@ -124,7 +128,10 @@
~PerThreadAssertScope() { data_->set(type, old_state_); }
- static bool IsAllowed() { return AssertData()->get(type); }
+ static bool IsAllowed() {
+ PerThreadAssertData* data = GetAssertData();
+ return data == NULL || data->get(type);
+ }
private:
bool old_state_;
diff --git a/src/compiler.cc b/src/compiler.cc
index 5de9d96..7b0b921 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1181,16 +1181,7 @@
Handle<Code> code = info->code();
if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))
return;
- Handle<String> script_name;
if (script->name()->IsString()) {
- script_name = Handle<String>(String::cast(script->name()));
- } else {
- Handle<Object> name = GetScriptNameOrSourceURL(script);
- if (!name.is_null() && name->IsString()) {
- script_name = Handle<String>::cast(name);
- }
- }
- if (!script_name.is_null()) {
int line_num = GetScriptLineNumber(script, shared->start_position()) + 1;
USE(line_num);
PROFILE(info->isolate(),
@@ -1198,7 +1189,7 @@
*code,
*shared,
info,
- String::cast(*script_name),
+ String::cast(script->name()),
line_num));
} else {
PROFILE(info->isolate(),
diff --git a/src/d8-debug.cc b/src/d8-debug.cc
index e1d29d9..aac7aab 100644
--- a/src/d8-debug.cc
+++ b/src/d8-debug.cc
@@ -68,7 +68,7 @@
// Get the toJSONProtocol function on the event and get the JSON format.
Local<String> to_json_fun_name = String::New("toJSONProtocol");
Local<Function> to_json_fun =
- Function::Cast(*event_data->Get(to_json_fun_name));
+ Local<Function>::Cast(event_data->Get(to_json_fun_name));
Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL);
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
@@ -91,9 +91,9 @@
// Get the debug command processor.
Local<String> fun_name = String::New("debugCommandProcessor");
- Local<Function> fun = Function::Cast(*exec_state->Get(fun_name));
+ Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name));
Local<Object> cmd_processor =
- Object::Cast(*fun->Call(exec_state, 0, NULL));
+ Local<Object>::Cast(fun->Call(exec_state, 0, NULL));
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
return;
diff --git a/src/d8.cc b/src/d8.cc
index a917dbd..4bfdb51 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1076,14 +1076,15 @@
}
static void ReadBufferWeakCallback(v8::Isolate* isolate,
- Persistent<Value>* object,
+ Persistent<ArrayBuffer>* array_buffer,
uint8_t* data) {
- size_t byte_length = ArrayBuffer::Cast(**object)->ByteLength();
+ size_t byte_length =
+ Local<ArrayBuffer>::New(isolate, *array_buffer)->ByteLength();
isolate->AdjustAmountOfExternalAllocatedMemory(
-static_cast<intptr_t>(byte_length));
delete[] data;
- object->Dispose(isolate);
+ array_buffer->Dispose();
}
void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
@@ -1103,7 +1104,7 @@
return;
}
Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length);
- v8::Persistent<v8::Value> weak_handle(isolate, buffer);
+ v8::Persistent<v8::ArrayBuffer> weak_handle(isolate, buffer);
weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback);
weak_handle.MarkIndependent();
isolate->AdjustAmountOfExternalAllocatedMemory(length);
diff --git a/src/debug.cc b/src/debug.cc
index 5d26ba2..0ffdd00 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -670,7 +670,7 @@
ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data);
// Find the location of the global handle.
Script** location =
- reinterpret_cast<Script**>(Utils::OpenHandle(**obj).location());
+ reinterpret_cast<Script**>(Utils::OpenPersistent(*obj).location());
ASSERT((*location)->IsScript());
// Remove the entry from the cache.
@@ -3066,13 +3066,14 @@
v8::Local<v8::String> fun_name =
v8::String::New("debugCommandProcessor");
v8::Local<v8::Function> fun =
- v8::Function::Cast(*api_exec_state->Get(fun_name));
+ v8::Local<v8::Function>::Cast(api_exec_state->Get(fun_name));
v8::Handle<v8::Boolean> running =
auto_continue ? v8::True() : v8::False();
static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { running };
- cmd_processor = v8::Object::Cast(*fun->Call(api_exec_state, kArgc, argv));
+ cmd_processor = v8::Local<v8::Object>::Cast(
+ fun->Call(api_exec_state, kArgc, argv));
if (try_catch.HasCaught()) {
PrintLn(try_catch.Exception());
return;
@@ -3112,7 +3113,7 @@
v8::Local<v8::Value> request;
v8::TryCatch try_catch;
fun_name = v8::String::New("processDebugRequest");
- fun = v8::Function::Cast(*cmd_processor->Get(fun_name));
+ fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name));
request = v8::String::New(command.text().start(),
command.text().length());
@@ -3125,7 +3126,7 @@
if (!try_catch.HasCaught()) {
// Get response string.
if (!response_val->IsUndefined()) {
- response = v8::String::Cast(*response_val);
+ response = v8::Local<v8::String>::Cast(response_val);
} else {
response = v8::String::New("");
}
@@ -3138,7 +3139,7 @@
// Get the running state.
fun_name = v8::String::New("isRunning");
- fun = v8::Function::Cast(*cmd_processor->Get(fun_name));
+ fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name));
static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { response };
v8::Local<v8::Value> running_val = fun->Call(cmd_processor, kArgc, argv);
diff --git a/src/handles.cc b/src/handles.cc
index 658bb2a..6859cd4 100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -347,7 +347,7 @@
static void ClearWrapperCache(v8::Isolate* v8_isolate,
Persistent<v8::Value>* handle,
void*) {
- Handle<Object> cache = Utils::OpenHandle(**handle);
+ Handle<Object> cache = Utils::OpenPersistent(handle);
JSValue* wrapper = JSValue::cast(*cache);
Foreign* foreign = Script::cast(wrapper->value())->wrapper();
ASSERT(foreign->foreign_address() ==
@@ -599,9 +599,6 @@
Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) {
Isolate* isolate = script->GetIsolate();
- if (!isolate->IsInitialized()) {
- return isolate->factory()->undefined_value();
- }
Handle<String> name_or_source_url_key =
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("nameOrSourceURL"));
diff --git a/src/heap.cc b/src/heap.cc
index 1df9fa1..5710b63 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -407,6 +407,8 @@
this->SizeOfObjects() / KB,
this->Available() / KB,
this->CommittedMemory() / KB);
+ PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n",
+ amount_of_external_allocated_memory_ / KB);
PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_);
}
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 3d0d550..e86d216 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -8919,9 +8919,11 @@
} else {
// The constructor function is both an operand to the instruction and an
// argument to the construct call.
+ Handle<JSFunction> array_function =
+ Handle<JSFunction>(isolate()->global_context()->array_function(),
+ isolate());
bool use_call_new_array = FLAG_optimize_constructed_arrays &&
- !(expr->target().is_null()) &&
- *(expr->target()) == isolate()->global_context()->array_function();
+ expr->target().is_identical_to(array_function);
CHECK_ALIVE(VisitArgument(expr->expression()));
HValue* constructor = HPushArgument::cast(Top())->argument();
@@ -8929,6 +8931,7 @@
HCallNew* call;
if (use_call_new_array) {
Handle<Cell> cell = expr->allocation_info_cell();
+ AddInstruction(new(zone()) HCheckFunction(constructor, array_function));
call = new(zone()) HCallNewArray(context, constructor, argument_count,
cell);
} else {
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 8b01a8b..c4c1e87 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -1994,20 +1994,20 @@
__ mov(eax, isolate()->factory()->undefined_value());
__ jmp(&l_next);
- // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; }
+ // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
__ bind(&l_catch);
handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
- __ mov(edx, Operand(esp, 1 * kPointerSize)); // iter
- __ push(edx); // iter
- __ push(eax); // exception
__ mov(ecx, isolate()->factory()->throw_string()); // "throw"
- Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(throw_ic); // iter.throw in eax
+ __ push(ecx); // "throw"
+ __ push(Operand(esp, 2 * kPointerSize)); // iter
+ __ push(eax); // exception
__ jmp(&l_call);
- // try { received = yield result.value }
+ // try { received = %yield result }
+ // Shuffle the received result above a try handler and yield it without
+ // re-boxing.
__ bind(&l_try);
- EmitCreateIteratorResult(false); // pop and box to eax
+ __ pop(eax); // result
__ PushTryHandler(StackHandler::CATCH, expr->index());
const int handler_size = StackHandlerConstants::kSize;
__ push(eax); // result
@@ -2024,40 +2024,22 @@
// receiver = iter; f = iter.next; arg = received;
__ bind(&l_next);
- __ mov(edx, Operand(esp, 1 * kPointerSize)); // iter
- __ push(edx); // iter
- __ push(eax); // received
__ mov(ecx, isolate()->factory()->next_string()); // "next"
- Handle<Code> next_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(next_ic); // iter.next in eax
+ __ push(ecx);
+ __ push(Operand(esp, 2 * kPointerSize)); // iter
+ __ push(eax); // received
- // result = f.call(receiver, arg);
+ // result = receiver[f](arg);
__ bind(&l_call);
- Label l_call_runtime;
- __ JumpIfSmi(eax, &l_call_runtime);
- __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
- __ j(not_equal, &l_call_runtime);
- __ mov(edi, eax);
- ParameterCount count(1);
- __ InvokeFunction(edi, count, CALL_FUNCTION,
- NullCallWrapper(), CALL_AS_METHOD);
+ Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1);
+ CallIC(ic);
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
- __ jmp(&l_loop);
- __ bind(&l_call_runtime);
- __ push(eax);
- __ CallRuntime(Runtime::kCall, 3);
+ __ Drop(1); // The key is still on the stack; drop it.
- // val = result.value; if (!result.done) goto l_try;
+ // if (!result.done) goto l_try;
__ bind(&l_loop);
- // result.value
__ push(eax); // save result
__ mov(edx, eax); // result
- __ mov(ecx, isolate()->factory()->value_string()); // "value"
- Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(value_ic); // result.value in eax
- __ pop(ebx); // result
- __ push(eax); // result.value
- __ mov(edx, ebx); // result
__ mov(ecx, isolate()->factory()->done_string()); // "done"
Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize();
CallIC(done_ic); // result.done in eax
@@ -2067,7 +2049,10 @@
__ j(zero, &l_try);
// result.value
- __ pop(eax); // result.value
+ __ pop(edx); // result
+ __ mov(ecx, isolate()->factory()->value_string()); // "value"
+ Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
+ CallIC(value_ic); // result.value in eax
context()->DropAndPlug(2, eax); // drop iter and g
break;
}
diff --git a/src/log.cc b/src/log.cc
index c653c14..908a368 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -435,7 +435,7 @@
event.code_len = code->instruction_size();
Handle<Script> script_handle =
script != NULL ? Handle<Script>(script) : Handle<Script>();
- event.script = v8::Handle<v8::Script>(ToApi<v8::Script>(script_handle));
+ event.script = ToApiHandle<v8::Script>(script_handle);
event.name.str = name;
event.name.len = name_len;
@@ -1728,18 +1728,10 @@
Handle<String> func_name(shared->DebugName());
if (shared->script()->IsScript()) {
Handle<Script> script(Script::cast(shared->script()));
- Handle<String> script_name;
if (script->name()->IsString()) {
- script_name = Handle<String>(String::cast(script->name()));
- } else {
- Handle<Object> name = GetScriptNameOrSourceURL(script);
- if (!name.is_null() && name->IsString()) {
- script_name = Handle<String>::cast(name);
- }
- }
- if (!script_name.is_null()) {
+ Handle<String> script_name(String::cast(script->name()));
int line_num = GetScriptLineNumber(script, shared->start_position());
- if (line_num > -1) {
+ if (line_num > 0) {
PROFILE(isolate_,
CodeCreateEvent(
Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
diff --git a/src/mips/assembler-mips-inl.h b/src/mips/assembler-mips-inl.h
index d922bfa..f518f05 100644
--- a/src/mips/assembler-mips-inl.h
+++ b/src/mips/assembler-mips-inl.h
@@ -232,24 +232,22 @@
}
-Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() {
- ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
+Handle<Cell> RelocInfo::target_cell_handle() {
+ ASSERT(rmode_ == RelocInfo::CELL);
Address address = Memory::Address_at(pc_);
- return Handle<JSGlobalPropertyCell>(
- reinterpret_cast<JSGlobalPropertyCell**>(address));
+ return Handle<Cell>(reinterpret_cast<Cell**>(address));
}
-JSGlobalPropertyCell* RelocInfo::target_cell() {
- ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
- return JSGlobalPropertyCell::FromValueAddress(Memory::Address_at(pc_));
+Cell* RelocInfo::target_cell() {
+ ASSERT(rmode_ == RelocInfo::CELL);
+ return Cell::FromValueAddress(Memory::Address_at(pc_));
}
-void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell,
- WriteBarrierMode mode) {
- ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
- Address address = cell->address() + JSGlobalPropertyCell::kValueOffset;
+void RelocInfo::set_target_cell(Cell* cell, WriteBarrierMode mode) {
+ ASSERT(rmode_ == RelocInfo::CELL);
+ Address address = cell->address() + Cell::kValueOffset;
Memory::Address_at(pc_) = address;
if (mode == UPDATE_WRITE_BARRIER && host() != NULL) {
// TODO(1550) We are passing NULL as a slot because cell can never be on
@@ -345,8 +343,8 @@
visitor->VisitEmbeddedPointer(this);
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
- } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
- visitor->VisitGlobalPropertyCell(this);
+ } else if (mode == RelocInfo::CELL) {
+ visitor->VisitCell(this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
visitor->VisitExternalReference(this);
} else if (RelocInfo::IsCodeAgeSequence(mode)) {
@@ -373,8 +371,8 @@
StaticVisitor::VisitEmbeddedPointer(heap, this);
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
- } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
- StaticVisitor::VisitGlobalPropertyCell(heap, this);
+ } else if (mode == RelocInfo::CELL) {
+ StaticVisitor::VisitCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(this);
} else if (RelocInfo::IsCodeAgeSequence(mode)) {
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index 3d0577e..5c8d08c 100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -3860,7 +3860,7 @@
__ Subu(inline_site, ra, scratch);
// Get the map location in scratch and patch it.
__ GetRelocatedValue(inline_site, scratch, v1); // v1 used as scratch.
- __ sw(map, FieldMemOperand(scratch, JSGlobalPropertyCell::kValueOffset));
+ __ sw(map, FieldMemOperand(scratch, Cell::kValueOffset));
}
// Register mapping: a3 is object map and t0 is function prototype.
@@ -5043,7 +5043,7 @@
masm->isolate()->heap()->the_hole_value());
// Load the cache state into a3.
- __ lw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ lw(a3, FieldMemOperand(a2, Cell::kValueOffset));
// A monomorphic cache hit or an already megamorphic state: invoke the
// function without changing the state.
@@ -5059,13 +5059,13 @@
// An uninitialized cache is patched with the function.
// Store a1 in the delay slot. This may or may not get overwritten depending
// on the result of the comparison.
- __ sw(a1, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(a1, FieldMemOperand(a2, Cell::kValueOffset));
// No need for a write barrier here - cells are rescanned.
// MegamorphicSentinel is an immortal immovable object (undefined) so no
// write-barrier is needed.
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
- __ sw(at, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(at, FieldMemOperand(a2, Cell::kValueOffset));
__ bind(&done);
}
@@ -5086,7 +5086,7 @@
masm->isolate()->heap()->the_hole_value());
// Load the cache state into a3.
- __ lw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ lw(a3, FieldMemOperand(a2, Cell::kValueOffset));
// A monomorphic cache hit or an already megamorphic state: invoke the
// function without changing the state.
@@ -5117,7 +5117,7 @@
// write-barrier is needed.
__ bind(&megamorphic);
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
- __ sw(at, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(at, FieldMemOperand(a2, Cell::kValueOffset));
__ jmp(&done);
// An uninitialized cache is patched with the function or sentinel to
@@ -5134,11 +5134,11 @@
TypeFeedbackCells::MonomorphicArraySentinel(masm->isolate(),
GetInitialFastElementsKind());
__ li(a3, Operand(initial_kind_sentinel));
- __ sw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(a3, FieldMemOperand(a2, Cell::kValueOffset));
__ Branch(&done);
__ bind(¬_array_function);
- __ sw(a1, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(a1, FieldMemOperand(a2, Cell::kValueOffset));
// No need for a write barrier here - cells are rescanned.
__ bind(&done);
@@ -5214,7 +5214,7 @@
ASSERT_EQ(*TypeFeedbackCells::MegamorphicSentinel(masm->isolate()),
masm->isolate()->heap()->undefined_value());
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
- __ sw(at, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(at, FieldMemOperand(a2, Cell::kValueOffset));
}
// Check for function proxy.
__ Branch(&non_function, ne, a3, Operand(JS_FUNCTION_PROXY_TYPE));
@@ -7776,14 +7776,13 @@
__ Assert(eq, "Unexpected initial map for Array function",
t0, Operand(MAP_TYPE));
- // We should either have undefined in ebx or a valid jsglobalpropertycell
+ // We should either have undefined in a2 or a valid cell
Label okay_here;
- Handle<Map> global_property_cell_map(
- masm->isolate()->heap()->global_property_cell_map());
+ Handle<Map> cell_map = masm->isolate()->factory()->cell_map();
__ Branch(&okay_here, eq, a2, Operand(undefined_sentinel));
__ lw(a3, FieldMemOperand(a2, 0));
- __ Assert(eq, "Expected property cell in register ebx",
- a3, Operand(global_property_cell_map));
+ __ Assert(eq, "Expected property cell in register a2",
+ a3, Operand(cell_map));
__ bind(&okay_here);
}
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index 2a51b1c..a16e478 100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -138,7 +138,7 @@
CompilationInfo* info = info_;
handler_table_ =
isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED);
- profiling_counter_ = isolate()->factory()->NewJSGlobalPropertyCell(
+ profiling_counter_ = isolate()->factory()->NewCell(
Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
SetFunctionPosition(function());
Comment cmnt(masm_, "[ function compiled by full code generator");
@@ -326,9 +326,9 @@
void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
__ li(a2, Operand(profiling_counter_));
- __ lw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ lw(a3, FieldMemOperand(a2, Cell::kValueOffset));
__ Subu(a3, a3, Operand(Smi::FromInt(delta)));
- __ sw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(a3, FieldMemOperand(a2, Cell::kValueOffset));
}
@@ -344,7 +344,7 @@
}
__ li(a2, Operand(profiling_counter_));
__ li(a3, Operand(Smi::FromInt(reset_value)));
- __ sw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset));
+ __ sw(a3, FieldMemOperand(a2, Cell::kValueOffset));
}
@@ -1164,15 +1164,13 @@
Label non_proxy;
__ bind(&fixed_array);
- Handle<JSGlobalPropertyCell> cell =
- isolate()->factory()->NewJSGlobalPropertyCell(
- Handle<Object>(
- Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker),
- isolate()));
+ Handle<Cell> cell = isolate()->factory()->NewCell(
+ Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker),
+ isolate()));
RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell);
__ LoadHeapObject(a1, cell);
__ li(a2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)));
- __ sw(a2, FieldMemOperand(a1, JSGlobalPropertyCell::kValueOffset));
+ __ sw(a2, FieldMemOperand(a1, Cell::kValueOffset));
__ li(a1, Operand(Smi::FromInt(1))); // Smi indicates slow check
__ lw(a2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object
@@ -2702,8 +2700,7 @@
flags = static_cast<CallFunctionFlags>(flags | RECORD_CALL_TARGET);
Handle<Object> uninitialized =
TypeFeedbackCells::UninitializedSentinel(isolate());
- Handle<JSGlobalPropertyCell> cell =
- isolate()->factory()->NewJSGlobalPropertyCell(uninitialized);
+ Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized);
RecordTypeFeedbackCell(expr->CallFeedbackId(), cell);
__ li(a2, Operand(cell));
@@ -2897,8 +2894,7 @@
// Record call targets in unoptimized code.
Handle<Object> uninitialized =
TypeFeedbackCells::UninitializedSentinel(isolate());
- Handle<JSGlobalPropertyCell> cell =
- isolate()->factory()->NewJSGlobalPropertyCell(uninitialized);
+ Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized);
RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell);
__ li(a2, Operand(cell));
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc
index f8d743e..0f02578 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -2439,8 +2439,7 @@
// We use Factory::the_hole_value() on purpose instead of loading from the
// root array to force relocation to be able to later patch with
// the cached map.
- Handle<JSGlobalPropertyCell> cell =
- factory()->NewJSGlobalPropertyCell(factory()->the_hole_value());
+ Handle<Cell> cell = factory()->NewCell(factory()->the_hole_value());
__ li(at, Operand(Handle<Object>(cell)));
__ lw(at, FieldMemOperand(at, JSGlobalPropertyCell::kValueOffset));
__ Branch(&cache_miss, ne, map, Operand(at));
@@ -2596,7 +2595,7 @@
void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
Register result = ToRegister(instr->result());
__ li(at, Operand(Handle<Object>(instr->hydrogen()->cell())));
- __ lw(result, FieldMemOperand(at, JSGlobalPropertyCell::kValueOffset));
+ __ lw(result, FieldMemOperand(at, Cell::kValueOffset));
if (instr->hydrogen()->RequiresHoleCheck()) {
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
DeoptimizeIf(eq, instr->environment(), result, Operand(at));
@@ -2630,13 +2629,13 @@
if (instr->hydrogen()->RequiresHoleCheck()) {
// We use a temp to check the payload.
Register payload = ToRegister(instr->temp());
- __ lw(payload, FieldMemOperand(cell, JSGlobalPropertyCell::kValueOffset));
+ __ lw(payload, FieldMemOperand(cell, Cell::kValueOffset));
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
DeoptimizeIf(eq, instr->environment(), payload, Operand(at));
}
// Store the value.
- __ sw(value, FieldMemOperand(cell, JSGlobalPropertyCell::kValueOffset));
+ __ sw(value, FieldMemOperand(cell, Cell::kValueOffset));
// Cells are always rescanned, so no write barrier here.
}
@@ -3904,8 +3903,25 @@
ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else if (instr->arity() == 1) {
+ Label done;
+ if (IsFastPackedElementsKind(kind)) {
+ Label packed_case;
+ // We might need a change here,
+ // look at the first argument.
+ __ lw(t1, MemOperand(sp, 0));
+ __ Branch(&packed_case, eq, t1, Operand(zero_reg));
+
+ ElementsKind holey_kind = GetHoleyElementsKind(kind);
+ ArraySingleArgumentConstructorStub stub(holey_kind,
+ disable_allocation_sites);
+ CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
+ __ jmp(&done);
+ __ bind(&packed_case);
+ }
+
ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
+ __ bind(&done);
} else {
ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
@@ -5001,10 +5017,9 @@
AllowDeferredHandleDereference smi_check;
if (isolate()->heap()->InNewSpace(*target)) {
Register reg = ToRegister(instr->value());
- Handle<JSGlobalPropertyCell> cell =
- isolate()->factory()->NewJSGlobalPropertyCell(target);
+ Handle<Cell> cell = isolate()->factory()->NewJSGlobalPropertyCell(target);
__ li(at, Operand(Handle<Object>(cell)));
- __ lw(at, FieldMemOperand(at, JSGlobalPropertyCell::kValueOffset));
+ __ lw(at, FieldMemOperand(at, Cell::kValueOffset));
DeoptimizeIf(ne, instr->environment(), reg,
Operand(at));
} else {
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc
index d55451b..15436e7 100644
--- a/src/mips/macro-assembler-mips.cc
+++ b/src/mips/macro-assembler-mips.cc
@@ -85,10 +85,9 @@
Handle<HeapObject> object) {
AllowDeferredHandleDereference using_raw_address;
if (isolate()->heap()->InNewSpace(*object)) {
- Handle<JSGlobalPropertyCell> cell =
- isolate()->factory()->NewJSGlobalPropertyCell(object);
+ Handle<Cell> cell = isolate()->factory()->NewCell(object);
li(result, Operand(cell));
- lw(result, FieldMemOperand(result, JSGlobalPropertyCell::kValueOffset));
+ lw(result, FieldMemOperand(result, Cell::kValueOffset));
} else {
li(result, Operand(object));
}
diff --git a/src/mips/stub-cache-mips.cc b/src/mips/stub-cache-mips.cc
index be32744..6e42242 100644
--- a/src/mips/stub-cache-mips.cc
+++ b/src/mips/stub-cache-mips.cc
@@ -420,12 +420,10 @@
Handle<Name> name,
Register scratch,
Label* miss) {
- Handle<JSGlobalPropertyCell> cell =
- GlobalObject::EnsurePropertyCell(global, name);
+ Handle<Cell> cell = GlobalObject::EnsurePropertyCell(global, name);
ASSERT(cell->value()->IsTheHole());
__ li(scratch, Operand(cell));
- __ lw(scratch,
- FieldMemOperand(scratch, JSGlobalPropertyCell::kValueOffset));
+ __ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
__ Branch(miss, ne, scratch, Operand(at));
}
@@ -1600,12 +1598,12 @@
void CallStubCompiler::GenerateLoadFunctionFromCell(
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Label* miss) {
// Get the value from the cell.
__ li(a3, Operand(cell));
- __ lw(a1, FieldMemOperand(a3, JSGlobalPropertyCell::kValueOffset));
+ __ lw(a1, FieldMemOperand(a3, Cell::kValueOffset));
// Check that the cell contains the same function.
if (heap()->InNewSpace(*function)) {
@@ -1675,7 +1673,7 @@
Handle<Code> CallStubCompiler::CompileArrayPushCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -1929,7 +1927,7 @@
Handle<Code> CallStubCompiler::CompileArrayPopCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -2011,7 +2009,7 @@
Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -2093,7 +2091,7 @@
Handle<Code> CallStubCompiler::CompileStringCharAtCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -2174,7 +2172,7 @@
Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -2247,7 +2245,7 @@
Handle<Code> CallStubCompiler::CompileMathFloorCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -2376,7 +2374,7 @@
Handle<Code> CallStubCompiler::CompileMathAbsCall(
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
// ----------- S t a t e -------------
@@ -2476,7 +2474,7 @@
const CallOptimization& optimization,
Handle<Object> object,
Handle<JSObject> holder,
- Handle<JSGlobalPropertyCell> cell,
+ Handle<Cell> cell,
Handle<JSFunction> function,
Handle<String> name) {
@@ -2649,7 +2647,7 @@
Handle<JSFunction> function) {
if (HasCustomCallGenerator(function)) {
Handle<Code> code = CompileCustomCall(object, holder,
- Handle<JSGlobalPropertyCell>::null(),
+ Handle<Cell>::null(),
function, Handle<String>::cast(name));
// A null handle means bail out to the regular compiler code below.
if (!code.is_null()) return code;
@@ -2899,13 +2897,11 @@
// global object. We bail out to the runtime system to do that.
__ li(scratch1(), Operand(cell));
__ LoadRoot(scratch2(), Heap::kTheHoleValueRootIndex);
- __ lw(scratch3(),
- FieldMemOperand(scratch1(), JSGlobalPropertyCell::kValueOffset));
+ __ lw(scratch3(), FieldMemOperand(scratch1(), Cell::kValueOffset));
__ Branch(&miss, eq, scratch3(), Operand(scratch2()));
// Store the value in the cell.
- __ sw(value(),
- FieldMemOperand(scratch1(), JSGlobalPropertyCell::kValueOffset));
+ __ sw(value(), FieldMemOperand(scratch1(), Cell::kValueOffset));
__ mov(v0, a0); // Stored value must be returned in v0.
// Cells are always rescanned, so no write barrier here.
@@ -3039,7 +3035,7 @@
// Get the value from the cell.
__ li(a3, Operand(cell));
- __ lw(t0, FieldMemOperand(a3, JSGlobalPropertyCell::kValueOffset));
+ __ lw(t0, FieldMemOperand(a3, Cell::kValueOffset));
// Check for deleted property if property can actually be deleted.
if (!is_dont_delete) {
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index 71e9e69..3ac475b 100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -392,7 +392,7 @@
// If we don't do this then we end up with a stray root pointing at the
// context even after we have disposed of the context.
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags, "mksnapshot");
- i::Object* raw_context = *(v8::Utils::OpenHandle(*context));
+ i::Object* raw_context = *v8::Utils::OpenPersistent(context);
context.Dispose(isolate);
CppByteSink sink(argv[1]);
// This results in a somewhat smaller snapshot, probably because it gets rid
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index 5418979..d15c400 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -79,7 +79,7 @@
v8::Persistent<v8::Value>* handle,
void* parameter) {
reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved(
- Utils::OpenHandle(**handle).location());
+ Utils::OpenPersistent(handle).location());
handle->Dispose(isolate);
}
diff --git a/src/runtime.cc b/src/runtime.cc
index 8711764..01165c8 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -655,7 +655,7 @@
void* data) {
Isolate* isolate = reinterpret_cast<Isolate*>(external_isolate);
HandleScope scope(isolate);
- Handle<Object> internal_object = Utils::OpenHandle(**object);
+ Handle<Object> internal_object = Utils::OpenPersistent(object);
Handle<JSArrayBuffer> array_buffer(JSArrayBuffer::cast(*internal_object));
if (!array_buffer->is_external()) {
@@ -711,11 +711,10 @@
SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length);
- v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate);
- v8::Persistent<v8::Value> weak_handle(
- external_isolate, v8::Utils::ToLocal(Handle<Object>::cast(array_buffer)));
- weak_handle.MakeWeak(external_isolate, data, ArrayBufferWeakCallback);
- weak_handle.MarkIndependent(external_isolate);
+ Handle<Object> persistent = isolate->global_handles()->Create(*array_buffer);
+ GlobalHandles::MakeWeak(persistent.location(), data, ArrayBufferWeakCallback);
+ GlobalHandles::MarkIndependent(persistent.location());
+
isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length);
return true;
diff --git a/src/v8.h b/src/v8.h
index b8a5ae4..b16374f 100644
--- a/src/v8.h
+++ b/src/v8.h
@@ -48,9 +48,6 @@
#error both DEBUG and NDEBUG are set
#endif
-// TODO(dcarney): remove this
-#define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
-
// Basic includes
#include "../include/v8.h"
#include "v8globals.h"
diff --git a/src/version.cc b/src/version.cc
index f6e8e2f..e443d37 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -34,7 +34,7 @@
// system so their names cannot be changed without changing the scripts.
#define MAJOR_VERSION 3
#define MINOR_VERSION 19
-#define BUILD_NUMBER 14
+#define BUILD_NUMBER 15
#define PATCH_LEVEL 0
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 74ccef9..4afcadb 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -2017,21 +2017,20 @@
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
__ jmp(&l_next);
- // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; }
+ // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
__ bind(&l_catch);
handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
- __ movq(rcx, Operand(rsp, 1 * kPointerSize)); // iter
- __ push(rcx); // iter
- __ push(rax); // exception
- __ movq(rax, rcx); // iter
__ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw"
- Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(throw_ic); // iter.throw in rax
+ __ push(rcx);
+ __ push(Operand(rsp, 2 * kPointerSize)); // iter
+ __ push(rax); // exception
__ jmp(&l_call);
- // try { received = yield result.value }
+ // try { received = %yield result }
+ // Shuffle the received result above a try handler and yield it without
+ // re-boxing.
__ bind(&l_try);
- EmitCreateIteratorResult(false); // pop and box to rax
+ __ pop(rax); // result
__ PushTryHandler(StackHandler::CATCH, expr->index());
const int handler_size = StackHandlerConstants::kSize;
__ push(rax); // result
@@ -2046,42 +2045,23 @@
__ bind(&l_resume); // received in rax
__ PopTryHandler();
- // receiver = iter; f = iter.next; arg = received;
+ // receiver = iter; f = 'next'; arg = received;
__ bind(&l_next);
- __ movq(rcx, Operand(rsp, 1 * kPointerSize)); // iter
- __ push(rcx); // iter
- __ push(rax); // received
- __ movq(rax, rcx); // iter
__ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next"
- Handle<Code> next_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(next_ic); // iter.next in rax
+ __ push(rcx);
+ __ push(Operand(rsp, 2 * kPointerSize)); // iter
+ __ push(rax); // received
- // result = f.call(receiver, arg);
+ // result = receiver[f](arg);
__ bind(&l_call);
- Label l_call_runtime;
- __ JumpIfSmi(rax, &l_call_runtime);
- __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
- __ j(not_equal, &l_call_runtime);
- __ movq(rdi, rax);
- ParameterCount count(1);
- __ InvokeFunction(rdi, count, CALL_FUNCTION,
- NullCallWrapper(), CALL_AS_METHOD);
+ Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1);
+ CallIC(ic);
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- __ jmp(&l_loop);
- __ bind(&l_call_runtime);
- __ push(rax);
- __ CallRuntime(Runtime::kCall, 3);
+ __ Drop(1); // The key is still on the stack; drop it.
- // val = result.value; if (!result.done) goto l_try;
+ // if (!result.done) goto l_try;
__ bind(&l_loop);
- // result.value
__ push(rax); // save result
- __ LoadRoot(rcx, Heap::kvalue_stringRootIndex); // "value"
- Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
- CallIC(value_ic); // result.value in rax
- __ pop(rbx); // result
- __ push(rax); // result.value
- __ movq(rax, rbx); // result
__ LoadRoot(rcx, Heap::kdone_stringRootIndex); // "done"
Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize();
CallIC(done_ic); // result.done in rax
@@ -2091,7 +2071,10 @@
__ j(zero, &l_try);
// result.value
- __ pop(rax); // result.value
+ __ pop(rax); // result
+ __ LoadRoot(rcx, Heap::kvalue_stringRootIndex); // "value"
+ Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
+ CallIC(value_ic); // result.value in rax
context()->DropAndPlug(2, rax); // drop iter and g
break;
}
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index c249b5e..193126a 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -200,7 +200,6 @@
const char* name_;
};
-namespace v8 {
// A LocalContext holds a reference to a v8::Context.
class LocalContext {
public:
@@ -209,24 +208,27 @@
v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- HandleScope scope(isolate);
- context_.Reset(isolate,
- Context::New(isolate,
- extensions,
- global_template,
- global_object));
- context_->Enter();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate,
+ extensions,
+ global_template,
+ global_object);
+ context_.Reset(isolate, context);
+ context->Enter();
// We can't do this later perhaps because of a fatal error.
- isolate_ = context_->GetIsolate();
+ isolate_ = context->GetIsolate();
}
virtual ~LocalContext() {
- context_->Exit();
- context_.Dispose(isolate_);
+ v8::HandleScope scope(isolate_);
+ v8::Local<v8::Context>::New(isolate_, context_)->Exit();
+ context_.Dispose();
}
- v8::Context* operator->() { return *context_; }
- v8::Context* operator*() { return *context_; }
+ v8::Context* operator->() {
+ return *reinterpret_cast<v8::Context**>(&context_);
+ }
+ v8::Context* operator*() { return operator->(); }
bool IsReady() { return !context_.IsEmpty(); }
v8::Local<v8::Context> local() {
@@ -237,8 +239,6 @@
v8::Persistent<v8::Context> context_;
v8::Isolate* isolate_;
};
-}
-typedef v8::LocalContext LocalContext;
static inline v8::Local<v8::Value> v8_num(double x) {
return v8::Number::New(x);
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 5d3a79d..5d38c21 100755
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2630,12 +2630,12 @@
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::Value> result =
+ v8::Local<v8::Value> result =
CompileRun("var ab1 = new ArrayBuffer(2);"
"var u8_a = new Uint8Array(ab1);"
"u8_a[0] = 0xAA;"
"u8_a[1] = 0xFF; u8_a.buffer");
- Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result);
+ Local<v8::ArrayBuffer> ab1 = Local<v8::ArrayBuffer>::Cast(result);
CHECK_EQ(2, static_cast<int>(ab1->ByteLength()));
CHECK(!ab1->IsExternal());
ScopedArrayBufferContents ab1_contents(ab1->Externalize());
@@ -2776,25 +2776,28 @@
"var f32a = new Float32Array(ab, 4, 255);"
"var f64a = new Float64Array(ab, 8, 127);");
- v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
+ v8::Handle<v8::ArrayBuffer> ab =
+ Local<v8::ArrayBuffer>::Cast(CompileRun("ab"));
- v8::Handle<v8::Uint8Array> u8a(v8::Uint8Array::Cast(*CompileRun("u8a")));
- v8::Handle<v8::Uint8ClampedArray> u8c(
- v8::Uint8ClampedArray::Cast(*CompileRun("u8c")));
- v8::Handle<v8::Int8Array> i8a(v8::Int8Array::Cast(*CompileRun("i8a")));
+ v8::Handle<v8::Uint8Array> u8a =
+ v8::Handle<v8::Uint8Array>::Cast(CompileRun("u8a"));
+ v8::Handle<v8::Uint8ClampedArray> u8c =
+ v8::Handle<v8::Uint8ClampedArray>::Cast(CompileRun("u8c"));
+ v8::Handle<v8::Int8Array> i8a =
+ v8::Handle<v8::Int8Array>::Cast(CompileRun("i8a"));
- v8::Handle<v8::Uint16Array> u16a(
- v8::Uint16Array::Cast(*CompileRun("u16a")));
- v8::Handle<v8::Int16Array> i16a(
- v8::Int16Array::Cast(*CompileRun("i16a")));
- v8::Handle<v8::Uint32Array> u32a(
- v8::Uint32Array::Cast(*CompileRun("u32a")));
- v8::Handle<v8::Int32Array> i32a(
- v8::Int32Array::Cast(*CompileRun("i32a")));
- v8::Handle<v8::Float32Array> f32a(
- v8::Float32Array::Cast(*CompileRun("f32a")));
- v8::Handle<v8::Float64Array> f64a(
- v8::Float64Array::Cast(*CompileRun("f64a")));
+ v8::Handle<v8::Uint16Array> u16a =
+ v8::Handle<v8::Uint16Array>::Cast(CompileRun("u16a"));
+ v8::Handle<v8::Int16Array> i16a =
+ v8::Handle<v8::Int16Array>::Cast(CompileRun("i16a"));
+ v8::Handle<v8::Uint32Array> u32a =
+ v8::Handle<v8::Uint32Array>::Cast(CompileRun("u32a"));
+ v8::Handle<v8::Int32Array> i32a =
+ v8::Handle<v8::Int32Array>::Cast(CompileRun("i32a"));
+ v8::Handle<v8::Float32Array> f32a =
+ v8::Handle<v8::Float32Array>::Cast(CompileRun("f32a"));
+ v8::Handle<v8::Float64Array> f64a =
+ v8::Handle<v8::Float64Array>::Cast(CompileRun("f64a"));
ScopedArrayBufferContents contents(ab->Externalize());
ab->Neuter();
@@ -3102,6 +3105,11 @@
}
+static UniqueId MakeUniqueId(const Persistent<Value>& p) {
+ return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p)));
+}
+
+
THREADED_TEST(ApiObjectGroups) {
LocalContext env;
v8::Isolate* iso = env->GetIsolate();
@@ -3121,16 +3129,16 @@
g1s1.Reset(iso, Object::New());
g1s2.Reset(iso, Object::New());
g1c1.Reset(iso, Object::New());
- g1s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g1s2.MakeWeak(iso, &counter, &WeakPointerCallback);
- g1c1.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g1s1.MakeWeak(&counter, &WeakPointerCallback);
+ g1s2.MakeWeak(&counter, &WeakPointerCallback);
+ g1c1.MakeWeak(&counter, &WeakPointerCallback);
g2s1.Reset(iso, Object::New());
g2s2.Reset(iso, Object::New());
g2c1.Reset(iso, Object::New());
- g2s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g2s2.MakeWeak(iso, &counter, &WeakPointerCallback);
- g2c1.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g2s1.MakeWeak(&counter, &WeakPointerCallback);
+ g2s2.MakeWeak(&counter, &WeakPointerCallback);
+ g2c1.MakeWeak(&counter, &WeakPointerCallback);
}
Persistent<Value> root(iso, g1s1); // make a root.
@@ -3139,14 +3147,14 @@
{
HandleScope scope(iso);
CHECK(Local<Object>::New(iso, g1s2.As<Object>())->
- Set(0, Local<Value>(*g2s2)));
+ Set(0, Local<Value>::New(iso, g2s2)));
CHECK(Local<Object>::New(iso, g2s1.As<Object>())->
- Set(0, Local<Value>(*g1s1)));
+ Set(0, Local<Value>::New(iso, g1s1)));
}
{
- UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
- UniqueId id2(reinterpret_cast<intptr_t>(*g2s2));
+ UniqueId id1 = MakeUniqueId(g1s1);
+ UniqueId id2 = MakeUniqueId(g2s2);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g1c1);
@@ -3163,7 +3171,7 @@
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
- root.MakeWeak(iso, &counter, &WeakPointerCallback);
+ root.MakeWeak(&counter, &WeakPointerCallback);
// But make children strong roots---all the objects (except for children)
// should be collectable now.
g1c1.ClearWeak(iso);
@@ -3171,8 +3179,8 @@
// Groups are deleted, rebuild groups.
{
- UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
- UniqueId id2(reinterpret_cast<intptr_t>(*g2s2));
+ UniqueId id1 = MakeUniqueId(g1s1);
+ UniqueId id2 = MakeUniqueId(g2s2);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g1c1);
@@ -3187,8 +3195,8 @@
CHECK_EQ(5, counter.NumberOfWeakCalls());
// And now make children weak again and collect them.
- g1c1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g2c1.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g1c1.MakeWeak(&counter, &WeakPointerCallback);
+ g2c1.MakeWeak(&counter, &WeakPointerCallback);
heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(7, counter.NumberOfWeakCalls());
@@ -3215,29 +3223,29 @@
HandleScope scope(iso);
g1s1.Reset(iso, Object::New());
g1s2.Reset(iso, Object::New());
- g1s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g1s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g1s1.MakeWeak(&counter, &WeakPointerCallback);
+ g1s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g1s1.IsWeak(iso));
CHECK(g1s2.IsWeak(iso));
g2s1.Reset(iso, Object::New());
g2s2.Reset(iso, Object::New());
- g2s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g2s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g2s1.MakeWeak(&counter, &WeakPointerCallback);
+ g2s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g2s1.IsWeak(iso));
CHECK(g2s2.IsWeak(iso));
g3s1.Reset(iso, Object::New());
g3s2.Reset(iso, Object::New());
- g3s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g3s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g3s1.MakeWeak(&counter, &WeakPointerCallback);
+ g3s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g3s1.IsWeak(iso));
CHECK(g3s2.IsWeak(iso));
g4s1.Reset(iso, Object::New());
g4s2.Reset(iso, Object::New());
- g4s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g4s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g4s1.MakeWeak(&counter, &WeakPointerCallback);
+ g4s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g4s1.IsWeak(iso));
CHECK(g4s2.IsWeak(iso));
}
@@ -3248,10 +3256,10 @@
// G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
// groups.
{
- UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
- UniqueId id2(reinterpret_cast<intptr_t>(*g2s1));
- UniqueId id3(reinterpret_cast<intptr_t>(*g3s1));
- UniqueId id4(reinterpret_cast<intptr_t>(*g4s1));
+ UniqueId id1 = MakeUniqueId(g1s1);
+ UniqueId id2 = MakeUniqueId(g2s1);
+ UniqueId id3 = MakeUniqueId(g3s1);
+ UniqueId id4 = MakeUniqueId(g4s1);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g2s1);
@@ -3274,14 +3282,14 @@
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
- root.MakeWeak(iso, &counter, &WeakPointerCallback);
+ root.MakeWeak(&counter, &WeakPointerCallback);
// Groups are deleted, rebuild groups.
{
- UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
- UniqueId id2(reinterpret_cast<intptr_t>(*g2s1));
- UniqueId id3(reinterpret_cast<intptr_t>(*g3s1));
- UniqueId id4(reinterpret_cast<intptr_t>(*g4s1));
+ UniqueId id1 = MakeUniqueId(g1s1);
+ UniqueId id2 = MakeUniqueId(g2s1);
+ UniqueId id3 = MakeUniqueId(g3s1);
+ UniqueId id4 = MakeUniqueId(g4s1);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g2s1);
@@ -3325,18 +3333,18 @@
HandleScope scope(iso);
g1s1.Reset(iso, Object::New());
g1s2.Reset(iso, Object::New());
- g1s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g1s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g1s1.MakeWeak(&counter, &WeakPointerCallback);
+ g1s2.MakeWeak(&counter, &WeakPointerCallback);
g2s1.Reset(iso, Object::New());
g2s2.Reset(iso, Object::New());
- g2s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g2s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g2s1.MakeWeak(&counter, &WeakPointerCallback);
+ g2s2.MakeWeak(&counter, &WeakPointerCallback);
g3s1.Reset(iso, Object::New());
g3s2.Reset(iso, Object::New());
- g3s1.MakeWeak(iso, &counter, &WeakPointerCallback);
- g3s2.MakeWeak(iso, &counter, &WeakPointerCallback);
+ g3s1.MakeWeak(&counter, &WeakPointerCallback);
+ g3s2.MakeWeak(&counter, &WeakPointerCallback);
}
// Make a root.
@@ -3356,16 +3364,16 @@
g3s2.MarkPartiallyDependent(iso);
iso->SetObjectGroupId(g1s1, UniqueId(1));
iso->SetObjectGroupId(g1s2, UniqueId(1));
- Local<Object>::New(iso, g1s1.As<Object>())->Set(v8_str("x"),
- Local<Value>(*g2s1));
+ Local<Object>::New(iso, g1s1.As<Object>())->Set(
+ v8_str("x"), Local<Value>::New(iso, g2s1));
iso->SetObjectGroupId(g2s1, UniqueId(2));
iso->SetObjectGroupId(g2s2, UniqueId(2));
- Local<Object>::New(iso, g2s1.As<Object>())->Set(v8_str("x"),
- Local<Value>(*g3s1));
+ Local<Object>::New(iso, g2s1.As<Object>())->Set(
+ v8_str("x"), Local<Value>::New(iso, g3s1));
iso->SetObjectGroupId(g3s1, UniqueId(3));
iso->SetObjectGroupId(g3s2, UniqueId(3));
- Local<Object>::New(iso, g3s1.As<Object>())->Set(v8_str("x"),
- Local<Value>(*g1s1));
+ Local<Object>::New(iso, g3s1.As<Object>())->Set(
+ v8_str("x"), Local<Value>::New(iso, g1s1));
}
v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>(
@@ -3376,7 +3384,7 @@
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
- root.MakeWeak(iso, &counter, &WeakPointerCallback);
+ root.MakeWeak(&counter, &WeakPointerCallback);
root.MarkPartiallyDependent(iso);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
@@ -3391,16 +3399,16 @@
g3s2.MarkPartiallyDependent(isolate);
iso->SetObjectGroupId(g1s1, UniqueId(1));
iso->SetObjectGroupId(g1s2, UniqueId(1));
- Local<Object>::New(iso, g1s1.As<Object>())->Set(v8_str("x"),
- Local<Value>(*g2s1));
+ Local<Object>::New(iso, g1s1.As<Object>())->Set(
+ v8_str("x"), Local<Value>::New(iso, g2s1));
iso->SetObjectGroupId(g2s1, UniqueId(2));
iso->SetObjectGroupId(g2s2, UniqueId(2));
- Local<Object>::New(iso, g2s1.As<Object>())->Set(v8_str("x"),
- Local<Value>(*g3s1));
+ Local<Object>::New(iso, g2s1.As<Object>())->Set(
+ v8_str("x"), Local<Value>::New(iso, g3s1));
iso->SetObjectGroupId(g3s1, UniqueId(3));
iso->SetObjectGroupId(g3s2, UniqueId(3));
- Local<Object>::New(iso, g3s1.As<Object>())->Set(v8_str("x"),
- Local<Value>(*g1s1));
+ Local<Object>::New(iso, g3s1.As<Object>())->Set(
+ v8_str("x"), Local<Value>::New(iso, g1s1));
}
heap->CollectGarbage(i::NEW_SPACE);
@@ -4853,7 +4861,7 @@
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
script->Run();
- CHECK_EQ(v8_num(4), Handle<Value>(*xValue));
+ CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
xValue.Dispose(context->GetIsolate());
xValue.Clear();
}
@@ -4870,7 +4878,7 @@
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
script->Run();
- CHECK_EQ(v8_num(4), Handle<Value>(*xValue));
+ CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
xValue.Dispose(context->GetIsolate());
xValue.Clear();
}
@@ -5095,7 +5103,7 @@
"for(i = 0; i < 80000; i++) { keys[i] = i; };"
"keys.length = 25; keys;"));
Local<Value> result = indexed_property_names_script->Run();
- return Local<v8::Array>(::v8::Array::Cast(*result));
+ return Local<v8::Array>::Cast(result);
}
@@ -5135,8 +5143,13 @@
"}"
"keys = f(0, 1, 2, 3);"
"keys;"));
- Local<Value> result = indexed_property_names_script->Run();
- return Local<v8::Array>(static_cast<v8::Array*>(::v8::Object::Cast(*result)));
+ Local<Object> result =
+ Local<Object>::Cast(indexed_property_names_script->Run());
+ // Have to populate the handle manually, as it's not Cast-able.
+ i::Handle<i::JSObject> o =
+ v8::Utils::OpenHandle<Object, i::JSObject>(result);
+ i::Handle<i::JSArray> array(reinterpret_cast<i::JSArray*>(*o));
+ return v8::Utils::ToLocal(array);
}
@@ -6247,7 +6260,7 @@
~Whammy() { script_.Dispose(isolate_); }
v8::Handle<Script> getScript() {
if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo"));
- return Local<Script>(*script_);
+ return Local<Script>::New(isolate_, script_);
}
public:
@@ -6276,9 +6289,7 @@
if (!prev.IsEmpty()) {
v8::Local<v8::Object>::New(info.GetIsolate(), prev)
->Set(v8_str("next"), obj);
- prev.MakeWeak<Value, Snorkel>(info.GetIsolate(),
- new Snorkel(),
- &HandleWeakReference);
+ prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference);
whammy->objects_[whammy->cursor_].Clear();
}
whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj);
@@ -6340,8 +6351,8 @@
bool object_a_disposed = false;
bool object_b_disposed = false;
- object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag);
- object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag);
+ object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
+ object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
CHECK(!object_b.IsIndependent(iso));
object_a.MarkIndependent(iso);
object_b.MarkIndependent(iso);
@@ -6402,7 +6413,7 @@
object.Reset(isolate, v8::Object::New());
}
bool disposed = false;
- object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]);
+ object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]);
object.MarkIndependent(isolate);
invoke_gc[outer_gc]();
CHECK(disposed);
@@ -6435,7 +6446,7 @@
o->Set(y_str, y_str);
}
bool revived = false;
- object.MakeWeak(isolate, &revived, &RevivingCallback);
+ object.MakeWeak(&revived, &RevivingCallback);
object.MarkIndependent(isolate);
HEAP->PerformScavenge();
CHECK(revived);
@@ -7211,12 +7222,12 @@
Local<Value> s2 = global->Get(v8_str("sym2"));
Local<Value> s3 = global->Get(v8_str("sym3"));
Local<Value> s4 = global->Get(v8_str("sym4"));
- CHECK(SameSymbol(sym0, Handle<String>(String::Cast(*s0))));
- CHECK(SameSymbol(sym0b, Handle<String>(String::Cast(*s0b))));
- CHECK(SameSymbol(sym1, Handle<String>(String::Cast(*s1))));
- CHECK(SameSymbol(sym2, Handle<String>(String::Cast(*s2))));
- CHECK(SameSymbol(sym3, Handle<String>(String::Cast(*s3))));
- CHECK(SameSymbol(sym4, Handle<String>(String::Cast(*s4))));
+ CHECK(SameSymbol(sym0, Handle<String>::Cast(s0)));
+ CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b)));
+ CHECK(SameSymbol(sym1, Handle<String>::Cast(s1)));
+ CHECK(SameSymbol(sym2, Handle<String>::Cast(s2)));
+ CHECK(SameSymbol(sym3, Handle<String>::Cast(s3)));
+ CHECK(SameSymbol(sym4, Handle<String>::Cast(s4)));
}
@@ -12161,9 +12172,7 @@
// global handle nodes are processed by PostGarbageCollectionProcessing
// in reverse allocation order, so if second allocated handle is deleted,
// weak callback of the first handle would be able to 'reallocate' it.
- handle1.MakeWeak<v8::Value, void>(isolate,
- NULL,
- NewPersistentHandleCallback);
+ handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback);
handle2.Dispose(isolate);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
@@ -12190,7 +12199,7 @@
handle1.Reset(isolate, v8::Object::New());
handle2.Reset(isolate, v8::Object::New());
}
- handle1.MakeWeak<v8::Value, void>(isolate, NULL, DisposeAndForceGcCallback);
+ handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback);
to_be_disposed.Reset(isolate, handle2);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
@@ -12205,7 +12214,7 @@
v8::Persistent<v8::Value>* handle,
void*) {
v8::HandleScope scope(isolate);
- v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
+ v8::Persistent<v8::Object>(isolate, v8::Object::New());
handle->Dispose(isolate);
}
@@ -12221,8 +12230,8 @@
handle2.Reset(isolate, v8::Object::New());
handle1.Reset(isolate, v8::Object::New());
}
- handle2.MakeWeak<v8::Value, void>(isolate, NULL, DisposingCallback);
- handle3.MakeWeak<v8::Value, void>(isolate, NULL, HandleCreatingCallback);
+ handle2.MakeWeak<v8::Value, void>(NULL, DisposingCallback);
+ handle3.MakeWeak<v8::Value, void>(NULL, HandleCreatingCallback);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
@@ -19297,10 +19306,10 @@
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
Local<Value> set_value = CompileRun("new Set();");
- Local<Object> set_object(Object::Cast(*set_value));
+ Local<Object> set_object(Local<Object>::Cast(set_value));
CHECK_EQ(0, set_object->InternalFieldCount());
Local<Value> map_value = CompileRun("new Map();");
- Local<Object> map_object(Object::Cast(*map_value));
+ Local<Object> map_object(Local<Object>::Cast(map_value));
CHECK_EQ(0, map_object->InternalFieldCount());
}
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 95930b4..a615fe9 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -917,89 +917,3 @@
cpu_profiler->DeleteAllCpuProfiles();
}
-
-
-static const char* cpu_profiler_sourceURL_source =
-"function start(timeout) {\n"
-" var start = Date.now();\n"
-" var duration = 0;\n"
-" do {\n"
-" try {\n"
-" duration = Date.now() - start;\n"
-" } catch(e) { }\n"
-" } while (duration < timeout);\n"
-" return duration;\n"
-"}\n"
-"//# sourceURL=cpu_profiler_sourceURL_source.js";
-
-
-TEST(SourceURLSupportForNewFunctions) {
- LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
-
- v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run();
- v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- int32_t profiling_interval_ms = 200;
-#if defined(_WIN32) || defined(_WIN64)
- // 200ms is not enough on Windows. See
- // https://code.google.com/p/v8/issues/detail?id=2628
- profiling_interval_ms = 500;
-#endif
-
- // Cold run.
- v8::Local<v8::String> profile_name = v8::String::New("my_profile");
- cpu_profiler->StartCpuProfiling(profile_name);
- v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) };
- function->Call(env->Global(), ARRAY_SIZE(args), args);
- const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
- CHECK_NE(NULL, profile);
-
- // Dump collected profile to have a better diagnostic in case of failure.
- reinterpret_cast<i::CpuProfile*>(
- const_cast<v8::CpuProfile*>(profile))->Print();
- const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
-
- CHECK_EQ(v8::String::New("cpu_profiler_sourceURL_source.js"),
- startNode->GetScriptResourceName());
-
- cpu_profiler->DeleteAllCpuProfiles();
-}
-
-TEST(LogExistingFunctionSourceURLCheck) {
- LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
-
- v8::Script::Compile(v8::String::New(cpu_profiler_sourceURL_source))->Run();
- v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- int32_t profiling_interval_ms = 200;
-
- // Warm up.
- v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) };
- function->Call(env->Global(), ARRAY_SIZE(args), args);
-
-#if defined(_WIN32) || defined(_WIN64)
- // 200ms is not enough on Windows. See
- // https://code.google.com/p/v8/issues/detail?id=2628
- profiling_interval_ms = 500;
-#endif
- v8::Local<v8::String> profile_name = v8::String::New("my_profile");
- cpu_profiler->StartCpuProfiling(profile_name);
- function->Call(env->Global(), ARRAY_SIZE(args), args);
- const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
- CHECK_NE(NULL, profile);
-
- // Dump collected profile to have a better diagnostic in case of failure.
- reinterpret_cast<i::CpuProfile*>(
- const_cast<v8::CpuProfile*>(profile))->Print();
- const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
- CHECK_EQ(v8::String::New("cpu_profiler_sourceURL_source.js"),
- startNode->GetScriptResourceName());
-
- cpu_profiler->DeleteAllCpuProfiles();
-}
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index b22092a..ed79205 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -143,6 +143,7 @@
inline ~DebugLocalContext() {
context_->Exit();
}
+ inline v8::Local<v8::Context> context() { return context_; }
inline v8::Context* operator->() { return *context_; }
inline v8::Context* operator*() { return *context_; }
inline bool IsReady() { return !context_.IsEmpty(); }
@@ -788,8 +789,8 @@
// Check whether the exception was uncaught.
v8::Local<v8::String> fun_name = v8::String::New("uncaught");
v8::Local<v8::Function> fun =
- v8::Function::Cast(*event_data->Get(fun_name));
- v8::Local<v8::Value> result = *fun->Call(event_data, 0, NULL);
+ v8::Local<v8::Function>::Cast(event_data->Get(fun_name));
+ v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL);
if (result->IsTrue()) {
uncaught_exception_hit_count++;
}
@@ -6457,7 +6458,7 @@
// Enter and run function in the context.
{
v8::Context::Scope context_scope(context_1);
- expected_context = v8::Local<v8::Context>(*context_1);
+ expected_context = context_1;
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_1->Global(), 0, NULL);
@@ -7041,11 +7042,11 @@
if (event == v8::Break) {
break_point_hit_count++;
CHECK(debugger_context == v8::Context::GetCurrent());
- v8::Handle<v8::Function> func(v8::Function::Cast(*CompileRun(
+ v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun(
"(function(exec_state) {\n"
" return (exec_state.frame(0).argumentValue(0).property('a').\n"
" value().value() == 1);\n"
- "})")));
+ "})"));
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { exec_state };
v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
@@ -7063,7 +7064,7 @@
// Save handles to the debugger and debugee contexts to be used in
// NamedGetterWithCallingContextCheck.
- debugee_context = v8::Local<v8::Context>(*env);
+ debugee_context = env.context();
debugger_context = v8::Utils::ToLocal(debug->debug_context());
// Create object with 'a' property accessor.
diff --git a/test/cctest/test-declarative-accessors.cc b/test/cctest/test-declarative-accessors.cc
index a14c7fa..2d2f5cd 100644
--- a/test/cctest/test-declarative-accessors.cc
+++ b/test/cctest/test-declarative-accessors.cc
@@ -120,8 +120,8 @@
CreateConstructor(context, "Accessible", internal_field, "x", descriptor);
// Setup object.
CompileRun("var accessible = new Accessible();");
- v8::Local<v8::Object> obj(
- v8::Object::Cast(*context->Global()->Get(v8_str("accessible"))));
+ v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
+ context->Global()->Get(v8_str("accessible")));
obj->SetAlignedPointerInInternalField(internal_field, internal_object);
bool added_accessor;
added_accessor = obj->SetAccessor(v8_str("y"), descriptor);
diff --git a/test/cctest/test-global-object.cc b/test/cctest/test-global-object.cc
index e8ffb8b..b124b27 100644
--- a/test/cctest/test-global-object.cc
+++ b/test/cctest/test-global-object.cc
@@ -36,7 +36,7 @@
TEST(StrictUndeclaredGlobalVariable) {
HandleScope scope(Isolate::GetCurrent());
v8::Local<v8::String> var_name = v8_str("x");
- v8::LocalContext context;
+ LocalContext context;
v8::TryCatch try_catch;
v8::Local<v8::Script> script = v8_compile("\"use strict\"; x = 42;");
v8::Handle<v8::Object> proto = v8::Object::New();
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 254cd1e..33b0fb9 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -1605,9 +1605,7 @@
CHECK(!HasWeakGlobalHandle());
v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New());
- handle.MakeWeak<v8::Value, void>(env->GetIsolate(),
- NULL,
- PersistentHandleCallback);
+ handle.MakeWeak<v8::Value, void>(NULL, PersistentHandleCallback);
CHECK(HasWeakGlobalHandle());
}
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 72d124f..d60deed 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2689,6 +2689,7 @@
TEST(Regression144230) {
+ i::FLAG_stress_compaction = false;
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
Heap* heap = isolate->heap();
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index d2ef02d..5daf8dd 100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -405,8 +405,7 @@
v8::FunctionTemplate::New());
obj->SetClassName(v8_str("Obj"));
v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
- v8::Local<v8::Signature> signature =
- v8::Signature::New(v8::Handle<v8::FunctionTemplate>(*obj));
+ v8::Local<v8::Signature> signature = v8::Signature::New(obj);
proto->Set(v8_str("method1"),
v8::FunctionTemplate::New(ObjMethod1,
v8::Handle<v8::Value>(),
diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc
index f6f2172..4487c16 100644
--- a/test/cctest/test-mark-compact.cc
+++ b/test/cctest/test-mark-compact.cc
@@ -557,7 +557,7 @@
}
} else { // 32-bit.
if (v8::internal::Snapshot::IsEnabled()) {
- CHECK_LE(delta, 2910 * 1024);
+ CHECK_LE(delta, 2942 * 1024);
} else {
CHECK_LE(delta, 3400 * 1024);
}
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index 0dd0265..3778fed 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -57,7 +57,7 @@
TEST(PerIsolateState) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context1;
+ LocalContext context1;
CompileRun(
"var count = 0;"
"var calls = 0;"
@@ -70,20 +70,20 @@
"(function() { obj.foo = 'bar'; })");
Handle<Value> notify_fun2;
{
- v8::LocalContext context2;
+ LocalContext context2;
context2->Global()->Set(String::New("obj"), obj);
notify_fun2 = CompileRun(
"(function() { obj.foo = 'baz'; })");
}
Handle<Value> notify_fun3;
{
- v8::LocalContext context3;
+ LocalContext context3;
context3->Global()->Set(String::New("obj"), obj);
notify_fun3 = CompileRun(
"(function() { obj.foo = 'bat'; })");
}
{
- v8::LocalContext context4;
+ LocalContext context4;
context4->Global()->Set(String::New("observer"), observer);
context4->Global()->Set(String::New("fun1"), notify_fun1);
context4->Global()->Set(String::New("fun2"), notify_fun2);
@@ -97,7 +97,7 @@
TEST(EndOfMicrotaskDelivery) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
CompileRun(
"var obj = {};"
"var count = 0;"
@@ -110,7 +110,7 @@
TEST(DeliveryOrdering) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
CompileRun(
"var obj1 = {};"
"var obj2 = {};"
@@ -141,7 +141,7 @@
TEST(DeliveryOrderingReentrant) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
CompileRun(
"var obj = {};"
"var reentered = false;"
@@ -172,7 +172,7 @@
TEST(DeliveryOrderingDeliverChangeRecords) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
CompileRun(
"var obj = {};"
"var ordering = [];"
@@ -197,14 +197,14 @@
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
// Initializing this context sets up initial hash tables.
- v8::LocalContext context;
+ LocalContext context;
Handle<Value> obj = CompileRun("obj = {};");
Handle<Value> observer = CompileRun(
"var ran = false;"
"(function() { ran = true })");
{
// As does initializing this context.
- v8::LocalContext context2;
+ LocalContext context2;
context2->Global()->Set(String::New("obj"), obj);
context2->Global()->Set(String::New("observer"), observer);
CompileRun(
@@ -224,7 +224,7 @@
TEST(GlobalObjectObservation) {
HarmonyIsolate isolate;
- v8::LocalContext context;
+ LocalContext context;
HandleScope scope(isolate.GetIsolate());
Handle<Object> global_proxy = context->Global();
Handle<Object> inner_global = global_proxy->GetPrototype().As<Object>();
@@ -256,7 +256,7 @@
// to the old context.
context->DetachGlobal();
{
- v8::LocalContext context2;
+ LocalContext context2;
context2->DetachGlobal();
context2->ReattachGlobal(global_proxy);
CompileRun(
@@ -271,7 +271,7 @@
// Attaching by passing to Context::New
{
// Delegates to Context::New
- v8::LocalContext context3(NULL, Handle<ObjectTemplate>(), global_proxy);
+ LocalContext context3(NULL, Handle<ObjectTemplate>(), global_proxy);
CompileRun(
"var records3 = [];"
"Object.observe(this, function(r) { [].push.apply(records3, r) });"
@@ -320,7 +320,7 @@
TEST(APITestBasicMutation) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
Handle<Object> obj = Handle<Object>::Cast(CompileRun(
"var records = [];"
"var obj = {};"
@@ -363,7 +363,7 @@
TEST(HiddenPrototypeObservation) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
Handle<FunctionTemplate> tmpl = FunctionTemplate::New();
tmpl->SetHiddenPrototype(true);
tmpl->InstanceTemplate()->Set(String::New("foo"), Number::New(75));
@@ -412,7 +412,7 @@
TEST(ObservationWeakMap) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
- v8::LocalContext context;
+ LocalContext context;
CompileRun(
"var obj = {};"
"Object.observe(obj, function(){});"
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 20c00c1..08c1375 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -556,7 +556,7 @@
v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
}
- Object* raw_context = *(v8::Utils::OpenHandle(*env));
+ i::Object* raw_context = *v8::Utils::OpenPersistent(env);
env.Dispose(v8_isolate);
diff --git a/test/cctest/test-weaktypedarrays.cc b/test/cctest/test-weaktypedarrays.cc
index ead5734..f2f6161 100644
--- a/test/cctest/test-weaktypedarrays.cc
+++ b/test/cctest/test-weaktypedarrays.cc
@@ -137,12 +137,12 @@
CompileRun("var ab1 = new ArrayBuffer(256);"
"var ab2 = new ArrayBuffer(256);"
"var ab3 = new ArrayBuffer(256);");
- v8::Handle<v8::ArrayBuffer> ab1(
- v8::ArrayBuffer::Cast(*CompileRun("ab1")));
- v8::Handle<v8::ArrayBuffer> ab2(
- v8::ArrayBuffer::Cast(*CompileRun("ab2")));
- v8::Handle<v8::ArrayBuffer> ab3(
- v8::ArrayBuffer::Cast(*CompileRun("ab3")));
+ v8::Handle<v8::ArrayBuffer> ab1 =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab1"));
+ v8::Handle<v8::ArrayBuffer> ab2 =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab2"));
+ v8::Handle<v8::ArrayBuffer> ab3 =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab3"));
CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap()));
CHECK(HasArrayBufferInWeakList(isolate->heap(),
@@ -166,8 +166,8 @@
for (int j = 1; j <= 3; j++) {
if (j == i) continue;
i::OS::SNPrintF(source, "ab%d", j);
- v8::Handle<v8::ArrayBuffer> ab(
- v8::ArrayBuffer::Cast(*CompileRun(source.start())));
+ v8::Handle<v8::ArrayBuffer> ab =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start()));
CHECK(HasArrayBufferInWeakList(isolate->heap(),
*v8::Utils::OpenHandle(*ab)));
}
@@ -285,10 +285,14 @@
constructor, constructor, constructor);
CompileRun(source.start());
- v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
- v8::Handle<TypedArray> ta1(TypedArray::Cast(*CompileRun("ta1")));
- v8::Handle<TypedArray> ta2(TypedArray::Cast(*CompileRun("ta2")));
- v8::Handle<TypedArray> ta3(TypedArray::Cast(*CompileRun("ta3")));
+ v8::Handle<v8::ArrayBuffer> ab =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
+ v8::Handle<TypedArray> ta1 =
+ v8::Handle<TypedArray>::Cast(CompileRun("ta1"));
+ v8::Handle<TypedArray> ta2 =
+ v8::Handle<TypedArray>::Cast(CompileRun("ta2"));
+ v8::Handle<TypedArray> ta3 =
+ v8::Handle<TypedArray>::Cast(CompileRun("ta3"));
CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()));
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
CHECK_EQ(3, CountTypedArrays(*iab));
@@ -306,14 +310,15 @@
{
v8::HandleScope s2(context->GetIsolate());
- v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
+ v8::Handle<v8::ArrayBuffer> ab =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
CHECK_EQ(2, CountTypedArrays(*iab));
for (int j = 1; j <= 3; j++) {
if (j == i) continue;
i::OS::SNPrintF(source, "ta%d", j);
- v8::Handle<TypedArray> ta(
- TypedArray::Cast(*CompileRun(source.start())));
+ v8::Handle<TypedArray> ta =
+ v8::Handle<TypedArray>::Cast(CompileRun(source.start()));
CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta)));
}
}
@@ -326,7 +331,8 @@
{
v8::HandleScope s3(context->GetIsolate());
- v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
+ v8::Handle<v8::ArrayBuffer> ab =
+ v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
CHECK_EQ(0, CountTypedArrays(*iab));
}
diff --git a/test/mjsunit/allocation-site-info.js b/test/mjsunit/allocation-site-info.js
index f533d61..69ee83e 100644
--- a/test/mjsunit/allocation-site-info.js
+++ b/test/mjsunit/allocation-site-info.js
@@ -315,7 +315,8 @@
instanceof_check(realmBArray);
%OptimizeFunctionOnNextCall(instanceof_check);
instanceof_check(Array);
- instanceof_check(realmBArray);
assertTrue(2 != %GetOptimizationStatus(instanceof_check));
+ instanceof_check(realmBArray);
+ assertTrue(1 != %GetOptimizationStatus(instanceof_check));
}
}
diff --git a/test/mjsunit/array-constructor-feedback.js b/test/mjsunit/array-constructor-feedback.js
new file mode 100644
index 0000000..d723121
--- /dev/null
+++ b/test/mjsunit/array-constructor-feedback.js
@@ -0,0 +1,106 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
+// Flags: --track-allocation-sites --noalways-opt
+
+// Test element kind of objects.
+// Since --smi-only-arrays affects builtins, its default setting at compile
+// time sticks if built with snapshot. If --smi-only-arrays is deactivated
+// by default, only a no-snapshot build actually has smi-only arrays enabled
+// in this test case. Depending on whether smi-only arrays are actually
+// enabled, this test takes the appropriate code path to check smi-only arrays.
+
+// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
+support_smi_only_arrays = true;
+optimize_constructed_arrays = true;
+
+if (support_smi_only_arrays) {
+ print("Tests include smi-only arrays.");
+} else {
+ print("Tests do NOT include smi-only arrays.");
+}
+
+if (optimize_constructed_arrays) {
+ print("Tests include constructed array optimizations.");
+} else {
+ print("Tests do NOT include constructed array optimizations.");
+}
+
+var elements_kind = {
+ fast_smi_only : 'fast smi only elements',
+ fast : 'fast elements',
+ fast_double : 'fast double elements',
+ dictionary : 'dictionary elements',
+ external_byte : 'external byte elements',
+ external_unsigned_byte : 'external unsigned byte elements',
+ external_short : 'external short elements',
+ external_unsigned_short : 'external unsigned short elements',
+ external_int : 'external int elements',
+ external_unsigned_int : 'external unsigned int elements',
+ external_float : 'external float elements',
+ external_double : 'external double elements',
+ external_pixel : 'external pixel elements'
+}
+
+function getKind(obj) {
+ if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only;
+ if (%HasFastObjectElements(obj)) return elements_kind.fast;
+ if (%HasFastDoubleElements(obj)) return elements_kind.fast_double;
+ if (%HasDictionaryElements(obj)) return elements_kind.dictionary;
+}
+
+function isHoley(obj) {
+ if (%HasFastHoleyElements(obj)) return true;
+ return false;
+}
+
+function assertKind(expected, obj, name_opt) {
+ if (!support_smi_only_arrays &&
+ expected == elements_kind.fast_smi_only) {
+ expected = elements_kind.fast;
+ }
+ assertEquals(expected, getKind(obj), name_opt);
+}
+
+if (support_smi_only_arrays && optimize_constructed_arrays) {
+ function bar0(t) {
+ return new t();
+ }
+
+ a = bar0(Array);
+ a[0] = 3.5;
+ b = bar0(Array);
+ assertKind(elements_kind.fast_double, b);
+ %OptimizeFunctionOnNextCall(bar0);
+ b = bar0(Array);
+ assertKind(elements_kind.fast_double, b);
+ assertTrue(2 != %GetOptimizationStatus(bar0));
+ // bar0 should deopt
+ b = bar0(Object);
+ assertTrue(1 != %GetOptimizationStatus(bar0));
+}
diff --git a/test/mjsunit/harmony/generators-iteration.js b/test/mjsunit/harmony/generators-iteration.js
index 2ca35f2..dc210d5 100644
--- a/test/mjsunit/harmony/generators-iteration.js
+++ b/test/mjsunit/harmony/generators-iteration.js
@@ -346,6 +346,36 @@
"foo",
[3, undefined]);
+// Test that yield* re-yields received results without re-boxing.
+function TestDelegatingYield() {
+ function results(results) {
+ var i = 0;
+ function next() {
+ return results[i++];
+ }
+ return { next: next }
+ }
+ function* yield_results(expected) {
+ return yield* results(expected);
+ }
+ function collect_results(iter) {
+ var ret = [];
+ var result;
+ do {
+ result = iter.next();
+ ret.push(result);
+ } while (!result.done);
+ return ret;
+ }
+ // We have to put a full result for the end, because the return will re-box.
+ var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
+
+ // Sanity check.
+ assertEquals(expected, collect_results(results(expected)));
+ assertEquals(expected, collect_results(yield_results(expected)));
+}
+TestDelegatingYield();
+
function TestTryCatch(instantiate) {
function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; }
function Sentinel() {}
diff --git a/test/mjsunit/regress/regress-2691.js b/test/mjsunit/regress/regress-2691.js
new file mode 100644
index 0000000..e17be10
--- /dev/null
+++ b/test/mjsunit/regress/regress-2691.js
@@ -0,0 +1,34 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --harmony-generators
+
+// Check that yield* on non-objects raises a TypeError.
+
+assertThrows('(function*() { yield* 10 })().next()', TypeError);
+assertThrows('(function*() { yield* {} })().next()', TypeError);
+assertThrows('(function*() { yield* undefined })().next()', TypeError);