Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: test/cctest/test-heap.cc

Issue 1406393005: [test] Move away from deprecated API for heap-related tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move delta between last PS1 and PS2 to new API Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-incremental-marking.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 945d0cded576cdebbd5580a357bc3f35cc9444de..b6cd09b5c487fcdd827840a9cbd9d7447ff08243 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -25,6 +25,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// TODO(jochen): Remove this after the setting is turned on globally.
+#define V8_IMMINENT_DEPRECATION_WARNINGS
+
#include <stdlib.h>
#include <utility>
@@ -43,7 +46,6 @@
#include "test/cctest/heap-tester.h"
#include "test/cctest/test-feedback-vector.h"
-using v8::Just;
namespace v8 {
namespace internal {
@@ -1648,7 +1650,7 @@ int CountNativeContexts() {
// Count the number of user functions in the weak list of optimized
// functions attached to a native context.
-static int CountOptimizedUserFunctions(v8::Handle<v8::Context> context) {
+static int CountOptimizedUserFunctions(v8::Local<v8::Context> context) {
int count = 0;
Handle<Context> icontext = v8::Utils::OpenHandle(*context);
Object* object = icontext->get(Context::OPTIMIZED_FUNCTIONS_LIST);
@@ -1676,7 +1678,7 @@ TEST(TestInternalWeakLists) {
Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap();
HandleScope scope(isolate);
- v8::Handle<v8::Context> ctx[kNumTestContexts];
+ v8::Local<v8::Context> ctx[kNumTestContexts];
if (!isolate->use_crankshaft()) return;
CHECK_EQ(0, CountNativeContexts());
@@ -1789,7 +1791,7 @@ static int CountNativeContextsWithGC(Isolate* isolate, int n) {
// Count the number of user functions in the weak list of optimized
// functions attached to a native context causing a GC after the
// specified number of elements.
-static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context,
+static int CountOptimizedUserFunctionsWithGC(v8::Local<v8::Context> context,
int n) {
int count = 0;
Handle<Context> icontext = v8::Utils::OpenHandle(*context);
@@ -1817,7 +1819,7 @@ TEST(TestInternalWeakListsTraverseWithGC) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
- v8::Handle<v8::Context> ctx[kNumTestContexts];
+ v8::Local<v8::Context> ctx[kNumTestContexts];
if (!isolate->use_crankshaft()) return;
CHECK_EQ(0, CountNativeContexts());
@@ -2389,16 +2391,19 @@ TEST(LeakNativeContextViaMap) {
CompileRun("var v = {x: 42}");
v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
- v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
+ v8::Local<v8::Value> v =
+ ctx1->Global()->Get(ctx1, v8_str("v")).ToLocalChecked();
ctx2->Enter();
- ctx2->Global()->Set(v8_str("o"), v);
+ CHECK(ctx2->Global()->Set(ctx2, v8_str("o"), v).FromJust());
v8::Local<v8::Value> res = CompileRun(
"function f() { return o.x; }"
"for (var i = 0; i < 10; ++i) f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
- CHECK_EQ(42, res->Int32Value());
- ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
+ CHECK_EQ(42, res->Int32Value(ctx2).FromJust());
+ CHECK(ctx2->Global()
+ ->Set(ctx2, v8_str("o"), v8::Int32::New(isolate, 0))
+ .FromJust());
ctx2->Exit();
v8::Local<v8::Context>::New(isolate, ctx1)->Exit();
ctx1p.Reset();
@@ -2435,16 +2440,19 @@ TEST(LeakNativeContextViaFunction) {
CompileRun("var v = function() { return 42; }");
v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
- v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
+ v8::Local<v8::Value> v =
+ ctx1->Global()->Get(ctx1, v8_str("v")).ToLocalChecked();
ctx2->Enter();
- ctx2->Global()->Set(v8_str("o"), v);
+ CHECK(ctx2->Global()->Set(ctx2, v8_str("o"), v).FromJust());
v8::Local<v8::Value> res = CompileRun(
"function f(x) { return x(); }"
"for (var i = 0; i < 10; ++i) f(o);"
"%OptimizeFunctionOnNextCall(f);"
"f(o);");
- CHECK_EQ(42, res->Int32Value());
- ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
+ CHECK_EQ(42, res->Int32Value(ctx2).FromJust());
+ CHECK(ctx2->Global()
+ ->Set(ctx2, v8_str("o"), v8::Int32::New(isolate, 0))
+ .FromJust());
ctx2->Exit();
ctx1->Exit();
ctx1p.Reset();
@@ -2479,16 +2487,19 @@ TEST(LeakNativeContextViaMapKeyed) {
CompileRun("var v = [42, 43]");
v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
- v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
+ v8::Local<v8::Value> v =
+ ctx1->Global()->Get(ctx1, v8_str("v")).ToLocalChecked();
ctx2->Enter();
- ctx2->Global()->Set(v8_str("o"), v);
+ CHECK(ctx2->Global()->Set(ctx2, v8_str("o"), v).FromJust());
v8::Local<v8::Value> res = CompileRun(
"function f() { return o[0]; }"
"for (var i = 0; i < 10; ++i) f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
- CHECK_EQ(42, res->Int32Value());
- ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
+ CHECK_EQ(42, res->Int32Value(ctx2).FromJust());
+ CHECK(ctx2->Global()
+ ->Set(ctx2, v8_str("o"), v8::Int32::New(isolate, 0))
+ .FromJust());
ctx2->Exit();
ctx1->Exit();
ctx1p.Reset();
@@ -2523,9 +2534,10 @@ TEST(LeakNativeContextViaMapProto) {
CompileRun("var v = { y: 42}");
v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
- v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
+ v8::Local<v8::Value> v =
+ ctx1->Global()->Get(ctx1, v8_str("v")).ToLocalChecked();
ctx2->Enter();
- ctx2->Global()->Set(v8_str("o"), v);
+ CHECK(ctx2->Global()->Set(ctx2, v8_str("o"), v).FromJust());
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var p = {x: 42};"
@@ -2535,8 +2547,10 @@ TEST(LeakNativeContextViaMapProto) {
"for (var i = 0; i < 10; ++i) f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
- CHECK_EQ(42, res->Int32Value());
- ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
+ CHECK_EQ(42, res->Int32Value(ctx2).FromJust());
+ CHECK(ctx2->Global()
+ ->Set(ctx2, v8_str("o"), v8::Int32::New(isolate, 0))
+ .FromJust());
ctx2->Exit();
ctx1->Exit();
ctx1p.Reset();
@@ -2560,6 +2574,7 @@ TEST(InstanceOfStubWriteBarrier) {
if (!CcTest::i_isolate()->use_crankshaft()) return;
if (i::FLAG_force_marking_deque_overflows) return;
v8::HandleScope outer_scope(CcTest::isolate());
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
v8::HandleScope scope(CcTest::isolate());
@@ -2577,8 +2592,9 @@ TEST(InstanceOfStubWriteBarrier) {
marking->Stop();
CcTest::heap()->StartIncrementalMarking();
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ i::Handle<JSFunction> f = i::Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CHECK(f->IsOptimized());
@@ -2593,10 +2609,10 @@ TEST(InstanceOfStubWriteBarrier) {
{
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::Object> global = CcTest::global();
- v8::Handle<v8::Function> g =
- v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
- g->Call(global, 0, NULL);
+ v8::Local<v8::Object> global = CcTest::global();
+ v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
+ global->Get(ctx, v8_str("g")).ToLocalChecked());
+ g->Call(ctx, global, 0, nullptr).ToLocalChecked();
}
CcTest::heap()->incremental_marking()->set_should_hurry(true);
@@ -2616,12 +2632,13 @@ TEST(PrototypeTransitionClearing) {
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
CompileRun("var base = {};");
- Handle<JSObject> baseObject =
- v8::Utils::OpenHandle(
- *v8::Handle<v8::Object>::Cast(
- CcTest::global()->Get(v8_str("base"))));
+ i::Handle<JSObject> baseObject =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(
+ CcTest::global()->Get(ctx, v8_str("base")).ToLocalChecked()));
+
int initialTransitions = NumberOfProtoTransitions(baseObject->map());
CompileRun(
@@ -2680,6 +2697,7 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft()) return;
v8::HandleScope outer_scope(CcTest::isolate());
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
v8::HandleScope scope(CcTest::isolate());
@@ -2693,8 +2711,9 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
"%OptimizeFunctionOnNextCall(f);"
"f();");
}
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ i::Handle<JSFunction> f = i::Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CHECK(f->IsOptimized());
IncrementalMarking* marking = CcTest::heap()->incremental_marking();
@@ -2720,6 +2739,7 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft()) return;
v8::HandleScope outer_scope(CcTest::isolate());
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
v8::HandleScope scope(CcTest::isolate());
@@ -2733,8 +2753,10 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
"%OptimizeFunctionOnNextCall(f);"
"f();");
}
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ i::Handle<JSFunction> f = i::Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
+
CHECK(f->IsOptimized());
CcTest::heap()->incremental_marking()->Stop();
@@ -2834,7 +2856,7 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
SimulateFullSpace(CcTest::heap()->new_space());
AlwaysAllocateScope always_allocate(CcTest::i_isolate());
v8::Local<v8::Value> res = CompileRun(
@@ -2848,11 +2870,15 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
"f(1); f(2); f(3);"
"%OptimizeFunctionOnNextCall(f);"
"f(4);");
- CHECK_EQ(
- 4, res.As<v8::Object>()->GetRealNamedProperty(v8_str("x"))->Int32Value());
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ CHECK_EQ(4, res.As<v8::Object>()
+ ->GetRealNamedProperty(ctx, v8_str("x"))
+ .ToLocalChecked()
+ ->Int32Value(ctx)
+ .FromJust());
+
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InNewSpace(*o));
}
@@ -2865,7 +2891,7 @@ TEST(OptimizedPretenuringAllocationFolding) {
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
// Grow new space unitl maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow();
@@ -2890,15 +2916,17 @@ TEST(OptimizedPretenuringAllocationFolding) {
v8::Local<v8::Value> res = CompileRun(source.start());
- v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
- Handle<JSObject> int_array_handle =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
- v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
- Handle<JSObject> double_array_handle =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
-
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ v8::Local<v8::Value> int_array =
+ v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked();
+ i::Handle<JSObject> int_array_handle =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array));
+ v8::Local<v8::Value> double_array =
+ v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked();
+ i::Handle<JSObject> double_array_handle =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array));
+
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(*o));
CHECK(CcTest::heap()->InOldSpace(*int_array_handle));
CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements()));
@@ -2939,8 +2967,8 @@ TEST(OptimizedPretenuringObjectArrayLiterals) {
v8::Local<v8::Value> res = CompileRun(source.start());
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(o->elements()));
CHECK(CcTest::heap()->InOldSpace(*o));
@@ -2980,8 +3008,8 @@ TEST(OptimizedPretenuringMixedInObjectProperties) {
v8::Local<v8::Value> res = CompileRun(source.start());
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(*o));
FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0);
@@ -3037,8 +3065,8 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
v8::Local<v8::Value> res = CompileRun(source.start());
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(*o));
CHECK(CcTest::heap()->InOldSpace(o->properties()));
@@ -3077,8 +3105,8 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) {
v8::Local<v8::Value> res = CompileRun(source.start());
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(o->elements()));
CHECK(CcTest::heap()->InOldSpace(*o));
@@ -3092,7 +3120,7 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
// Grow new space unitl maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow();
@@ -3116,15 +3144,16 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
v8::Local<v8::Value> res = CompileRun(source.start());
- v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
- Handle<JSObject> int_array_handle =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
- v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
- Handle<JSObject> double_array_handle =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
+ v8::Local<v8::Value> int_array =
+ v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked();
+ i::Handle<JSObject> int_array_handle =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array));
+ v8::Local<v8::Value> double_array =
+ v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked();
+ i::Handle<JSObject> double_array_handle =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array));
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(*o));
CHECK(CcTest::heap()->InOldSpace(*int_array_handle));
CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements()));
@@ -3140,7 +3169,7 @@ TEST(OptimizedPretenuringNestedObjectLiterals) {
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
// Grow new space unitl maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow();
@@ -3165,15 +3194,16 @@ TEST(OptimizedPretenuringNestedObjectLiterals) {
v8::Local<v8::Value> res = CompileRun(source.start());
- v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0"));
+ v8::Local<v8::Value> int_array_1 =
+ v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked();
Handle<JSObject> int_array_handle_1 =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1));
- v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1"));
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array_1));
+ v8::Local<v8::Value> int_array_2 =
+ v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked();
Handle<JSObject> int_array_handle_2 =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2));
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(int_array_2));
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(*o));
CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1));
CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements()));
@@ -3189,7 +3219,7 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
// Grow new space unitl maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow();
@@ -3215,16 +3245,16 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> double_array_1 =
- v8::Object::Cast(*res)->Get(v8_str("0"));
- Handle<JSObject> double_array_handle_1 =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1));
+ v8::Object::Cast(*res)->Get(ctx, v8_str("0")).ToLocalChecked();
+ i::Handle<JSObject> double_array_handle_1 =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array_1));
v8::Local<v8::Value> double_array_2 =
- v8::Object::Cast(*res)->Get(v8_str("1"));
- Handle<JSObject> double_array_handle_2 =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2));
+ v8::Object::Cast(*res)->Get(ctx, v8_str("1")).ToLocalChecked();
+ i::Handle<JSObject> double_array_handle_2 =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(double_array_2));
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InOldSpace(*o));
CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1));
CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements()));
@@ -3240,7 +3270,7 @@ TEST(OptimizedAllocationArrayLiterals) {
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = new Array(1, 2, 3);"
@@ -3250,11 +3280,14 @@ TEST(OptimizedAllocationArrayLiterals) {
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
- CHECK_EQ(static_cast<int>(3.14),
- v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
+ CHECK_EQ(static_cast<int>(3.14), v8::Object::Cast(*res)
+ ->Get(ctx, v8_str("0"))
+ .ToLocalChecked()
+ ->Int32Value(ctx)
+ .FromJust());
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ i::Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
CHECK(CcTest::heap()->InNewSpace(o->elements()));
}
@@ -3274,6 +3307,7 @@ TEST(Regress1465) {
i::FLAG_retain_maps_for_n_gc = 0;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
static const int transitions_count = 256;
CompileRun("function F() {}");
@@ -3287,10 +3321,8 @@ TEST(Regress1465) {
CompileRun("var root = new F;");
}
- Handle<JSObject> root =
- v8::Utils::OpenHandle(
- *v8::Handle<v8::Object>::Cast(
- CcTest::global()->Get(v8_str("root"))));
+ i::Handle<JSObject> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(
+ CcTest::global()->Get(ctx, v8_str("root")).ToLocalChecked()));
// Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map());
@@ -3319,10 +3351,11 @@ static void AddTransitions(int transitions_count) {
}
-static Handle<JSObject> GetByName(const char* name) {
- return v8::Utils::OpenHandle(
- *v8::Handle<v8::Object>::Cast(
- CcTest::global()->Get(v8_str(name))));
+static i::Handle<JSObject> GetByName(const char* name) {
+ return v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(
+ CcTest::global()
+ ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(name))
+ .ToLocalChecked()));
}
@@ -3482,10 +3515,10 @@ TEST(Regress2143a) {
// Explicitly request GC to perform final marking step and sweeping.
CcTest::heap()->CollectAllGarbage();
- Handle<JSObject> root =
- v8::Utils::OpenHandle(
- *v8::Handle<v8::Object>::Cast(
- CcTest::global()->Get(v8_str("root"))));
+ Handle<JSObject> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(
+ CcTest::global()
+ ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root"))
+ .ToLocalChecked()));
// The root object should be in a sane state.
CHECK(root->IsJSObject());
@@ -3525,10 +3558,10 @@ TEST(Regress2143b) {
// Explicitly request GC to perform final marking step and sweeping.
CcTest::heap()->CollectAllGarbage();
- Handle<JSObject> root =
- v8::Utils::OpenHandle(
- *v8::Handle<v8::Object>::Cast(
- CcTest::global()->Get(v8_str("root"))));
+ Handle<JSObject> root = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(
+ CcTest::global()
+ ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root"))
+ .ToLocalChecked()));
// The root object should be in a sane state.
CHECK(root->IsJSObject());
@@ -3615,11 +3648,13 @@ TEST(CountForcedGC) {
TEST(PrintSharedFunctionInfo) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
const char* source = "f = function() { return 987654321; }\n"
"g = function() { return 123456789; }\n";
CompileRun(source);
- Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g")))));
+ i::Handle<JSFunction> g = i::Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("g")).ToLocalChecked())));
OFStream os(stdout);
g->shared()->Print(os);
@@ -3633,27 +3668,28 @@ TEST(IncrementalMarkingPreservesMonomorphicCallIC) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> fun1, fun2;
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
LocalContext env;
CompileRun("function fun() {};");
- fun1 = env->Global()->Get(v8_str("fun"));
+ fun1 = env->Global()->Get(env.local(), v8_str("fun")).ToLocalChecked();
}
{
LocalContext env;
CompileRun("function fun() {};");
- fun2 = env->Global()->Get(v8_str("fun"));
+ fun2 = env->Global()->Get(env.local(), v8_str("fun")).ToLocalChecked();
}
// Prepare function f that contains type feedback for closures
// originating from two different native contexts.
- CcTest::global()->Set(v8_str("fun1"), fun1);
- CcTest::global()->Set(v8_str("fun2"), fun2);
+ CHECK(CcTest::global()->Set(ctx, v8_str("fun1"), fun1).FromJust());
+ CHECK(CcTest::global()->Set(ctx, v8_str("fun2"), fun2).FromJust());
CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
FeedbackVectorHelper feedback_helper(feedback_vector);
@@ -3725,10 +3761,10 @@ TEST(ICInBuiltInIsClearedAppropriately) {
{
LocalContext env;
v8::Local<v8::Value> res = CompileRun("Function.apply");
- Handle<JSObject> maybe_apply =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
- apply = Handle<JSFunction>::cast(maybe_apply);
- Handle<TypeFeedbackVector> vector(apply->shared()->feedback_vector());
+ i::Handle<JSObject> maybe_apply =
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res));
+ apply = i::Handle<JSFunction>::cast(maybe_apply);
+ i::Handle<TypeFeedbackVector> vector(apply->shared()->feedback_vector());
FeedbackVectorHelper feedback_helper(vector);
CHECK_EQ(1, feedback_helper.slot_count());
CheckVectorIC(apply, 0, UNINITIALIZED);
@@ -3753,15 +3789,15 @@ TEST(IncrementalMarkingPreservesMonomorphicConstructor) {
if (i::FLAG_always_opt) return;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
// Prepare function f that contains a monomorphic IC for object
// originating from the same native context.
CompileRun(
"function fun() { this.x = 1; };"
"function f(o) { return new o(); } f(fun); f(fun);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
-
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector());
CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell());
@@ -3779,21 +3815,23 @@ TEST(IncrementalMarkingClearsMonomorphicConstructor) {
Isolate* isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> fun1;
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
LocalContext env;
CompileRun("function fun() { this.x = 1; };");
- fun1 = env->Global()->Get(v8_str("fun"));
+ fun1 = env->Global()->Get(env.local(), v8_str("fun")).ToLocalChecked();
}
// Prepare function f that contains a monomorphic constructor for object
// originating from a different native context.
- CcTest::global()->Set(v8_str("fun1"), fun1);
+ CHECK(CcTest::global()->Set(ctx, v8_str("fun1"), fun1).FromJust());
CompileRun(
"function fun() { this.x = 1; };"
"function f(o) { return new o(); } f(fun1); f(fun1);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector());
@@ -3813,13 +3851,14 @@ TEST(IncrementalMarkingPreservesMonomorphicIC) {
if (i::FLAG_always_opt) return;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
-
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
// Prepare function f that contains a monomorphic IC for object
// originating from the same native context.
CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
"function f(o) { return o.x; } f(obj); f(obj);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, MONOMORPHIC);
@@ -3835,19 +3874,21 @@ TEST(IncrementalMarkingClearsMonomorphicIC) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> obj1;
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
LocalContext env;
CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
- obj1 = env->Global()->Get(v8_str("obj"));
+ obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
}
// Prepare function f that contains a monomorphic IC for object
// originating from a different native context.
- CcTest::global()->Set(v8_str("obj1"), obj1);
+ CHECK(CcTest::global()->Set(ctx, v8_str("obj1"), obj1).FromJust());
CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, MONOMORPHIC);
@@ -3865,26 +3906,28 @@ TEST(IncrementalMarkingPreservesPolymorphicIC) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> obj1, obj2;
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
LocalContext env;
CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
- obj1 = env->Global()->Get(v8_str("obj"));
+ obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
}
{
LocalContext env;
CompileRun("function fun() { this.x = 2; }; var obj = new fun();");
- obj2 = env->Global()->Get(v8_str("obj"));
+ obj2 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
}
// Prepare function f that contains a polymorphic IC for objects
// originating from two different native contexts.
- CcTest::global()->Set(v8_str("obj1"), obj1);
- CcTest::global()->Set(v8_str("obj2"), obj2);
+ CHECK(CcTest::global()->Set(ctx, v8_str("obj1"), obj1).FromJust());
+ CHECK(CcTest::global()->Set(ctx, v8_str("obj2"), obj2).FromJust());
CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, POLYMORPHIC);
@@ -3901,26 +3944,28 @@ TEST(IncrementalMarkingClearsPolymorphicIC) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> obj1, obj2;
+ v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
{
LocalContext env;
CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
- obj1 = env->Global()->Get(v8_str("obj"));
+ obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
}
{
LocalContext env;
CompileRun("function fun() { this.x = 2; }; var obj = new fun();");
- obj2 = env->Global()->Get(v8_str("obj"));
+ obj2 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
}
// Prepare function f that contains a polymorphic IC for objects
// originating from two different native contexts.
- CcTest::global()->Set(v8_str("obj1"), obj1);
- CcTest::global()->Set(v8_str("obj2"), obj2);
+ CHECK(CcTest::global()->Set(ctx, v8_str("obj1"), obj1).FromJust());
+ CHECK(CcTest::global()->Set(ctx, v8_str("obj2"), obj2).FromJust());
CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, POLYMORPHIC);
@@ -3966,10 +4011,14 @@ void ReleaseStackTraceDataTest(v8::Isolate* isolate, const char* source,
SourceResource* resource = new SourceResource(i::StrDup(source));
{
v8::HandleScope scope(isolate);
- v8::Handle<v8::String> source_string =
- v8::String::NewExternal(isolate, resource);
+ v8::Local<v8::Context> ctx = isolate->GetCurrentContext();
+ v8::Local<v8::String> source_string =
+ v8::String::NewExternalOneByte(isolate, resource).ToLocalChecked();
i_isolate->heap()->CollectAllAvailableGarbage();
- v8::Script::Compile(source_string)->Run();
+ v8::Script::Compile(ctx, source_string)
+ .ToLocalChecked()
+ ->Run(ctx)
+ .ToLocalChecked();
CHECK(!resource->IsDisposed());
}
// i_isolate->heap()->CollectAllAvailableGarbage();
@@ -4047,6 +4096,7 @@ TEST(Regress159140) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
+ LocalContext env;
Heap* heap = isolate->heap();
HandleScope scope(isolate);
@@ -4072,13 +4122,15 @@ TEST(Regress159140) {
"%OptimizeFunctionOnNextCall(f); f(3);"
"%OptimizeFunctionOnNextCall(h); h(3);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("f")).ToLocalChecked())));
CHECK(f->is_compiled());
CompileRun("f = null;");
- Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g")))));
+ Handle<JSFunction> g = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("g")).ToLocalChecked())));
CHECK(g->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -4115,6 +4167,7 @@ TEST(Regress165495) {
// but make sure the optimized code is unreachable.
{
HandleScope inner_scope(isolate);
+ LocalContext env;
CompileRun("function mkClosure() {"
" return function(x) { return x + 1; };"
"}"
@@ -4122,8 +4175,9 @@ TEST(Regress165495) {
"f(1); f(2);"
"%OptimizeFunctionOnNextCall(f); f(3);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("f")).ToLocalChecked())));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -4161,14 +4215,16 @@ TEST(Regress169209) {
Handle<SharedFunctionInfo> shared1;
{
HandleScope inner_scope(isolate);
+ LocalContext env;
CompileRun("function f() { return 'foobar'; }"
"function g(x) { if (x) f(); }"
"f();"
"g(false);"
"g(false);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("f")).ToLocalChecked())));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -4183,12 +4239,14 @@ TEST(Regress169209) {
Handle<SharedFunctionInfo> shared2;
{
HandleScope inner_scope(isolate);
+ LocalContext env;
CompileRun("function flushMe() { return 0; }"
"flushMe(1);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(
- v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast(
- CcTest::global()->Get(v8_str("flushMe")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(env.local(), v8_str("flushMe"))
+ .ToLocalChecked())));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -4220,6 +4278,7 @@ TEST(Regress169928) {
i::FLAG_crankshaft = false;
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
+ LocalContext env;
Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
@@ -4245,7 +4304,9 @@ TEST(Regress169928) {
v8_str("fastliteralcase(mote, 2.5);");
v8::Local<v8::String> array_name = v8_str("mote");
- CcTest::global()->Set(array_name, v8::Int32::New(CcTest::isolate(), 0));
+ CHECK(CcTest::global()
+ ->Set(env.local(), array_name, v8::Int32::New(CcTest::isolate(), 0))
+ .FromJust());
// First make sure we flip spaces
CcTest::heap()->CollectGarbage(NEW_SPACE);
@@ -4277,13 +4338,16 @@ TEST(Regress169928) {
addr_obj, AllocationMemento::kSize + kPointerSize);
// Give the array a name, making sure not to allocate strings.
- v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array);
- CcTest::global()->Set(array_name, array_obj);
+ v8::Local<v8::Object> array_obj = v8::Utils::ToLocal(array);
+ CHECK(CcTest::global()->Set(env.local(), array_name, array_obj).FromJust());
// This should crash with a protection violation if we are running a build
// with the bug.
AlwaysAllocateScope aa_scope(isolate);
- v8::Script::Compile(mote_code_string)->Run();
+ v8::Script::Compile(env.local(), mote_code_string)
+ .ToLocalChecked()
+ ->Run(env.local())
+ .ToLocalChecked();
}
@@ -4294,6 +4358,7 @@ TEST(Regress513507) {
i::FLAG_gc_global = true;
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
+ LocalContext env;
Heap* heap = isolate->heap();
HandleScope scope(isolate);
@@ -4304,8 +4369,9 @@ TEST(Regress513507) {
CompileRun("function f() { return 1 }"
"f(); %OptimizeFunctionOnNextCall(f); f();");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("f")).ToLocalChecked())));
shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate));
CompileRun("f = null");
}
@@ -4317,8 +4383,9 @@ TEST(Regress513507) {
CompileRun("function g() { return 2 }"
"g(); %OptimizeFunctionOnNextCall(g); g();");
- Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g")))));
+ Handle<JSFunction> g = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("g")).ToLocalChecked())));
code = inner_scope.CloseAndEscape(handle(g->code(), isolate));
if (!code->is_optimized_code()) return;
}
@@ -4345,6 +4412,7 @@ TEST(Regress514122) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
+ LocalContext env;
Heap* heap = isolate->heap();
HandleScope scope(isolate);
@@ -4358,8 +4426,9 @@ TEST(Regress514122) {
CompileRun("function f() { return 1 }"
"f(); %OptimizeFunctionOnNextCall(f); f();");
- Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("f")).ToLocalChecked())));
shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate));
CompileRun("f = null");
}
@@ -4371,8 +4440,9 @@ TEST(Regress514122) {
CompileRun("function g() { return 2 }"
"g(); %OptimizeFunctionOnNextCall(g); g();");
- Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g")))));
+ Handle<JSFunction> g = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()->Get(env.local(), v8_str("g")).ToLocalChecked())));
code = inner_scope.CloseAndEscape(handle(g->code(), isolate));
if (!code->is_optimized_code()) return;
}
@@ -4446,6 +4516,7 @@ TEST(Regress513496) {
// outer optimized code is kept in the optimized code map.
Handle<SharedFunctionInfo> shared;
{
+ LocalContext context;
HandleScope inner_scope(isolate);
CompileRun(
"function g(x) { return x + 1 }"
@@ -4457,7 +4528,9 @@ TEST(Regress513496) {
"%OptimizeFunctionOnNextCall(f); f(3);");
Handle<JSFunction> g = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("g")))));
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(context.local(), v8_str("g"))
+ .ToLocalChecked())));
CHECK(g->shared()->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -4465,7 +4538,9 @@ TEST(Regress513496) {
}
Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(context.local(), v8_str("f"))
+ .ToLocalChecked())));
CHECK(f->is_compiled());
shared = inner_scope.CloseAndEscape(handle(f->shared(), isolate));
CompileRun("f = null");
@@ -4653,8 +4728,10 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) {
Code* function_bar = Code::cast(
WeakCell::cast(site->dependent_code()->object_at(index))->value());
Handle<JSFunction> bar_handle = Handle<JSFunction>::cast(
- v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast(
- CcTest::global()->Get(v8_str("bar")))));
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()
+ ->Get(context.local(), v8_str("bar"))
+ .ToLocalChecked())));
CHECK_EQ(bar_handle->code(), function_bar);
}
@@ -4701,7 +4778,9 @@ TEST(CellsInOptimizedCodeAreWeak) {
" return bar;})();");
Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("bar")))));
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(context.local(), v8_str("bar"))
+ .ToLocalChecked())));
code = scope.CloseAndEscape(Handle<Code>(bar->code()));
}
@@ -4740,7 +4819,9 @@ TEST(ObjectsInOptimizedCodeAreWeak) {
"bar();");
Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("bar")))));
+ *v8::Local<v8::Function>::Cast(CcTest::global()
+ ->Get(context.local(), v8_str("bar"))
+ .ToLocalChecked())));
code = scope.CloseAndEscape(Handle<Code>(bar->code()));
}
@@ -4804,7 +4885,8 @@ TEST(NoWeakHashTableLeakWithIncrementalMarking) {
}
-static Handle<JSFunction> OptimizeDummyFunction(const char* name) {
+static Handle<JSFunction> OptimizeDummyFunction(v8::Isolate* isolate,
+ const char* name) {
EmbeddedVector<char, 256> source;
SNPrintF(source,
"function %s() { return 0; }"
@@ -4812,8 +4894,11 @@ static Handle<JSFunction> OptimizeDummyFunction(const char* name) {
"%%OptimizeFunctionOnNextCall(%s);"
"%s();", name, name, name, name, name);
CompileRun(source.start());
- Handle<JSFunction> fun = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str(name)))));
+ i::Handle<JSFunction> fun = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()
+ ->Get(isolate->GetCurrentContext(), v8_str(name))
+ .ToLocalChecked())));
return fun;
}
@@ -4842,8 +4927,10 @@ TEST(NextCodeLinkIsWeak) {
int code_chain_length_before, code_chain_length_after;
{
HandleScope scope(heap->isolate());
- Handle<JSFunction> mortal = OptimizeDummyFunction("mortal");
- Handle<JSFunction> immortal = OptimizeDummyFunction("immortal");
+ Handle<JSFunction> mortal =
+ OptimizeDummyFunction(CcTest::isolate(), "mortal");
+ Handle<JSFunction> immortal =
+ OptimizeDummyFunction(CcTest::isolate(), "immortal");
CHECK_EQ(immortal->code()->next_code_link(), mortal->code());
code_chain_length_before = GetCodeChainLength(immortal->code());
// Keep the immortal code and let the mortal code die.
@@ -4914,14 +5001,17 @@ TEST(WeakFunctionInConstructor) {
i::FLAG_stress_compaction = false;
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
+ LocalContext env;
v8::HandleScope scope(isolate);
CompileRun(
"function createObj(obj) {"
" return new obj();"
"}");
- Handle<JSFunction> createObj = Handle<JSFunction>::cast(
- v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast(
- CcTest::global()->Get(v8_str("createObj")))));
+ i::Handle<JSFunction> createObj = Handle<JSFunction>::cast(
+ v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
+ CcTest::global()
+ ->Get(env.local(), v8_str("createObj"))
+ .ToLocalChecked())));
v8::Persistent<v8::Object> garbage;
{
@@ -4933,7 +5023,10 @@ TEST(WeakFunctionInConstructor) {
" createObj(hat);"
" return hat;"
" })();";
- garbage.Reset(isolate, CompileRun(source)->ToObject(isolate));
+ garbage.Reset(isolate, CompileRun(env.local(), source)
+ .ToLocalChecked()
+ ->ToObject(env.local())
+ .ToLocalChecked());
}
weak_ic_cleared = false;
garbage.SetWeak(&garbage, &ClearWeakIC, v8::WeakCallbackType::kParameter);
@@ -4968,11 +5061,15 @@ void CheckWeakness(const char* source) {
i::FLAG_stress_compaction = false;
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
+ LocalContext env;
v8::HandleScope scope(isolate);
v8::Persistent<v8::Object> garbage;
{
v8::HandleScope scope(isolate);
- garbage.Reset(isolate, CompileRun(source)->ToObject(isolate));
+ garbage.Reset(isolate, CompileRun(env.local(), source)
+ .ToLocalChecked()
+ ->ToObject(env.local())
+ .ToLocalChecked());
}
weak_ic_cleared = false;
garbage.SetWeak(&garbage, &ClearWeakIC, v8::WeakCallbackType::kParameter);
@@ -5315,7 +5412,7 @@ TEST(AddInstructionChangesNewSpacePromotion) {
v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap();
-
+ LocalContext env;
CompileRun(
"function add(a, b) {"
" return a + b;"
@@ -5336,13 +5433,13 @@ TEST(AddInstructionChangesNewSpacePromotion) {
"%OptimizeFunctionOnNextCall(crash);"
"crash(1);");
- v8::Handle<v8::Object> global = CcTest::global();
- v8::Handle<v8::Function> g =
- v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash")));
- v8::Handle<v8::Value> args1[] = { v8_num(1) };
+ v8::Local<v8::Object> global = CcTest::global();
+ v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
+ global->Get(env.local(), v8_str("crash")).ToLocalChecked());
+ v8::Local<v8::Value> args1[] = {v8_num(1)};
heap->DisableInlineAllocation();
heap->set_allocation_timeout(1);
- g->Call(global, 1, args1);
+ g->Call(env.local(), global, 1, args1).ToLocalChecked();
heap->CollectAllGarbage();
}
@@ -5357,9 +5454,9 @@ TEST(CEntryStubOOM) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
- v8::V8::SetFatalErrorHandler(OnFatalErrorExpectOOM);
+ CcTest::isolate()->SetFatalErrorHandler(OnFatalErrorExpectOOM);
- v8::Handle<v8::Value> result = CompileRun(
+ v8::Local<v8::Value> result = CompileRun(
"%SetFlags('--gc-interval=1');"
"var a = [];"
"a.__proto__ = [];"
@@ -5415,9 +5512,11 @@ TEST(Regress357137) {
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope hscope(isolate);
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "interrupt"),
- v8::FunctionTemplate::New(isolate, RequestInterrupt));
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "interrupt", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, RequestInterrupt));
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
DCHECK(!context.IsEmpty());
v8::Context::Scope cscope(context);
@@ -5428,7 +5527,7 @@ TEST(Regress357137) {
"eval('function f() {' + locals + 'return function() { return v0; }; }');"
"interrupt();" // This triggers a fake stack overflow in f.
"f()()");
- CHECK_EQ(42.0, result->ToNumber(isolate)->Value());
+ CHECK_EQ(42.0, result->ToNumber(context).ToLocalChecked()->Value());
}
@@ -5474,7 +5573,7 @@ TEST(ArrayShiftSweeping) {
"array;");
Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result));
CHECK(heap->InOldSpace(o->elements()));
CHECK(heap->InOldSpace(*o));
Page* page = Page::FromAddress(o->elements()->address());
@@ -5623,7 +5722,7 @@ TEST(Regress3631) {
}
// Incrementally mark the backing store.
Handle<JSObject> obj =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result));
Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj));
while (!Marking::IsBlack(
Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) &&
@@ -5683,7 +5782,7 @@ TEST(Regress3877) {
HandleScope inner_scope(isolate);
v8::Local<v8::Value> result = CompileRun("cls.prototype");
Handle<JSObject> proto =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result));
weak_prototype = inner_scope.CloseAndEscape(factory->NewWeakCell(proto));
}
CHECK(!weak_prototype->cleared());
@@ -5711,7 +5810,7 @@ Handle<WeakCell> AddRetainedMap(Isolate* isolate, Heap* heap) {
v8::Local<v8::Value> result =
CompileRun("(function () { return {x : 10}; })();");
Handle<JSObject> proto =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
+ v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result));
Map::SetPrototype(map, proto);
heap->AddRetainedMap(map);
return inner_scope.CloseAndEscape(Map::WeakCellForMap(map));
@@ -5899,6 +5998,7 @@ TEST(BootstrappingExports) {
FLAG_expose_natives_as = "utils";
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
+ LocalContext env;
if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
@@ -5909,8 +6009,12 @@ TEST(BootstrappingExports) {
{
v8::HandleScope scope(isolate);
v8::Local<v8::String> name = v8_str("utils");
- utils.Reset(isolate, CcTest::global()->Get(name)->ToObject(isolate));
- CcTest::global()->Delete(name);
+ utils.Reset(isolate, CcTest::global()
+ ->Get(env.local(), name)
+ .ToLocalChecked()
+ ->ToObject(env.local())
+ .ToLocalChecked());
+ CHECK(CcTest::global()->Delete(env.local(), name).FromJust());
}
utils.SetWeak(&utils, UtilsHasBeenCollected,
@@ -5929,7 +6033,10 @@ TEST(Regress1878) {
v8::HandleScope scope(isolate);
v8::Local<v8::Function> constructor = v8::Utils::CallableToLocal(
CcTest::i_isolate()->internal_array_function());
- CcTest::global()->Set(v8_str("InternalArray"), constructor);
+ LocalContext env;
+ CHECK(CcTest::global()
+ ->Set(env.local(), v8_str("InternalArray"), constructor)
+ .FromJust());
v8::TryCatch try_catch(isolate);
@@ -6083,9 +6190,11 @@ TEST(MessageObjectLeak) {
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "check"),
- v8::FunctionTemplate::New(isolate, CheckLeak));
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ global->Set(
+ v8::String::NewFromUtf8(isolate, "check", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::FunctionTemplate::New(isolate, CheckLeak));
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope cscope(context);
@@ -6136,7 +6245,7 @@ TEST(CanonicalSharedFunctionInfo) {
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
global->Set(isolate, "check", v8::FunctionTemplate::New(
isolate, CheckEqualSharedFunctionInfos));
global->Set(isolate, "remove",
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698