Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc
index 06afdd2..4e95952 100644
--- a/test/cctest/test-decls.cc
+++ b/test/cctest/test-decls.cc
@@ -60,25 +60,24 @@
}
}
- void Check(const char* source,
- int get, int set, int has,
+ void Check(const char* source, int get, int set, int has,
Expectations expectations,
- v8::Handle<Value> value = Local<Value>());
+ v8::Local<Value> value = Local<Value>());
int get_count() const { return get_count_; }
int set_count() const { return set_count_; }
int query_count() const { return query_count_; }
protected:
- virtual v8::Handle<Value> Get(Local<Name> key);
- virtual v8::Handle<Value> Set(Local<Name> key, Local<Value> value);
- virtual v8::Handle<Integer> Query(Local<Name> key);
+ virtual v8::Local<Value> Get(Local<Name> key);
+ virtual v8::Local<Value> Set(Local<Name> key, Local<Value> value);
+ virtual v8::Local<Integer> Query(Local<Name> key);
void InitializeIfNeeded();
// Perform optional initialization steps on the context after it has
// been created. Defaults to none but may be overwritten.
- virtual void PostInitializeContext(Handle<Context> context) {}
+ virtual void PostInitializeContext(Local<Context> context) {}
// Get the holder for the interceptor. Default to the instance template
// but may be overwritten.
@@ -130,42 +129,48 @@
context_.Reset(isolate, context);
context->Enter();
is_initialized_ = true;
+ // Reset counts. Bootstrapping might have called into the interceptor.
+ get_count_ = 0;
+ set_count_ = 0;
+ query_count_ = 0;
PostInitializeContext(context);
}
-void DeclarationContext::Check(const char* source,
- int get, int set, int query,
+void DeclarationContext::Check(const char* source, int get, int set, int query,
Expectations expectations,
- v8::Handle<Value> value) {
+ v8::Local<Value> value) {
InitializeIfNeeded();
// A retry after a GC may pollute the counts, so perform gc now
// to avoid that.
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
HandleScope scope(CcTest::isolate());
- TryCatch catcher;
+ TryCatch catcher(CcTest::isolate());
catcher.SetVerbose(true);
- Local<Script> script =
- Script::Compile(String::NewFromUtf8(CcTest::isolate(), source));
+ Local<Context> context = CcTest::isolate()->GetCurrentContext();
+ MaybeLocal<Script> script = Script::Compile(
+ context,
+ String::NewFromUtf8(CcTest::isolate(), source, v8::NewStringType::kNormal)
+ .ToLocalChecked());
if (expectations == EXPECT_ERROR) {
CHECK(script.IsEmpty());
return;
}
CHECK(!script.IsEmpty());
- Local<Value> result = script->Run();
+ MaybeLocal<Value> result = script.ToLocalChecked()->Run(context);
CHECK_EQ(get, get_count());
CHECK_EQ(set, set_count());
CHECK_EQ(query, query_count());
if (expectations == EXPECT_RESULT) {
CHECK(!catcher.HasCaught());
if (!value.IsEmpty()) {
- CHECK_EQ(value, result);
+ CHECK(value->Equals(context, result.ToLocalChecked()).FromJust());
}
} else {
CHECK(expectations == EXPECT_EXCEPTION);
CHECK(catcher.HasCaught());
if (!value.IsEmpty()) {
- CHECK_EQ(value, catcher.Exception());
+ CHECK(value->Equals(context, catcher.Exception()).FromJust());
}
}
// Clean slate for the next test.
@@ -204,24 +209,25 @@
}
-v8::Handle<Value> DeclarationContext::Get(Local<Name> key) {
- return v8::Handle<Value>();
+v8::Local<Value> DeclarationContext::Get(Local<Name> key) {
+ return v8::Local<Value>();
}
-v8::Handle<Value> DeclarationContext::Set(Local<Name> key, Local<Value> value) {
- return v8::Handle<Value>();
+v8::Local<Value> DeclarationContext::Set(Local<Name> key, Local<Value> value) {
+ return v8::Local<Value>();
}
-v8::Handle<Integer> DeclarationContext::Query(Local<Name> key) {
- return v8::Handle<Integer>();
+v8::Local<Integer> DeclarationContext::Query(Local<Name> key) {
+ return v8::Local<Integer>();
}
// Test global declaration of a property the interceptor doesn't know
// about and doesn't handle.
TEST(Unknown) {
+ i::FLAG_legacy_const = true;
HandleScope scope(CcTest::isolate());
v8::V8::Initialize();
@@ -264,13 +270,14 @@
class AbsentPropertyContext: public DeclarationContext {
protected:
- virtual v8::Handle<Integer> Query(Local<Name> key) {
- return v8::Handle<Integer>();
+ virtual v8::Local<Integer> Query(Local<Name> key) {
+ return v8::Local<Integer>();
}
};
TEST(Absent) {
+ i::FLAG_legacy_const = true;
v8::Isolate* isolate = CcTest::isolate();
v8::V8::Initialize();
HandleScope scope(isolate);
@@ -328,13 +335,13 @@
AppearingPropertyContext() : state_(DECLARE) { }
protected:
- virtual v8::Handle<Integer> Query(Local<Name> key) {
+ virtual v8::Local<Integer> Query(Local<Name> key) {
switch (state_) {
case DECLARE:
// Force declaration by returning that the
// property is absent.
state_ = INITIALIZE_IF_ASSIGN;
- return Handle<Integer>();
+ return Local<Integer>();
case INITIALIZE_IF_ASSIGN:
// Return that the property is present so we only get the
// setter called when initializing with a value.
@@ -345,7 +352,7 @@
break;
}
// Do the lookup in the object.
- return v8::Handle<Integer>();
+ return v8::Local<Integer>();
}
private:
@@ -354,6 +361,7 @@
TEST(Appearing) {
+ i::FLAG_legacy_const = true;
v8::V8::Initialize();
HandleScope scope(CcTest::isolate());
@@ -397,7 +405,7 @@
public:
ExistsInPrototypeContext() { InitializeIfNeeded(); }
protected:
- virtual v8::Handle<Integer> Query(Local<Name> key) {
+ virtual v8::Local<Integer> Query(Local<Name> key) {
// Let it seem that the property exists in the prototype object.
return Integer::New(isolate(), v8::None);
}
@@ -410,6 +418,7 @@
TEST(ExistsInPrototype) {
+ i::FLAG_legacy_const = true;
HandleScope scope(CcTest::isolate());
// Sanity check to make sure that the holder of the interceptor
@@ -456,9 +465,9 @@
class AbsentInPrototypeContext: public DeclarationContext {
protected:
- virtual v8::Handle<Integer> Query(Local<Name> key) {
+ virtual v8::Local<Integer> Query(Local<Name> key) {
// Let it seem that the property is absent in the prototype object.
- return Handle<Integer>();
+ return Local<Integer>();
}
// Use the prototype as the holder for the interceptors.
@@ -491,18 +500,21 @@
}
protected:
- virtual v8::Handle<Integer> Query(Local<Name> key) {
+ virtual v8::Local<Integer> Query(Local<Name> key) {
// Let it seem that the property exists in the hidden prototype object.
return Integer::New(isolate(), v8::None);
}
// Install the hidden prototype after the global object has been created.
- virtual void PostInitializeContext(Handle<Context> context) {
+ virtual void PostInitializeContext(Local<Context> context) {
Local<Object> global_object = context->Global();
- Local<Object> hidden_proto = hidden_proto_->GetFunction()->NewInstance();
+ Local<Object> hidden_proto = hidden_proto_->GetFunction(context)
+ .ToLocalChecked()
+ ->NewInstance(context)
+ .ToLocalChecked();
Local<Object> inner_global =
Local<Object>::Cast(global_object->GetPrototype());
- inner_global->SetPrototype(hidden_proto);
+ inner_global->SetPrototype(context, hidden_proto).FromJust();
}
// Use the hidden prototype as the holder for the interceptors.
@@ -516,6 +528,7 @@
TEST(ExistsInHiddenPrototype) {
+ i::FLAG_legacy_const = true;
HandleScope scope(CcTest::isolate());
{ ExistsInHiddenPrototypeContext context;
@@ -563,30 +576,31 @@
context_->Exit();
}
- void Check(const char* source,
- Expectations expectations,
- v8::Handle<Value> value = Local<Value>()) {
+ void Check(const char* source, Expectations expectations,
+ v8::Local<Value> value = Local<Value>()) {
HandleScope scope(context_->GetIsolate());
- TryCatch catcher;
+ TryCatch catcher(context_->GetIsolate());
catcher.SetVerbose(true);
- Local<Script> script =
- Script::Compile(String::NewFromUtf8(context_->GetIsolate(), source));
+ MaybeLocal<Script> script = Script::Compile(
+ context_, String::NewFromUtf8(context_->GetIsolate(), source,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
if (expectations == EXPECT_ERROR) {
CHECK(script.IsEmpty());
return;
}
CHECK(!script.IsEmpty());
- Local<Value> result = script->Run();
+ MaybeLocal<Value> result = script.ToLocalChecked()->Run(context_);
if (expectations == EXPECT_RESULT) {
CHECK(!catcher.HasCaught());
if (!value.IsEmpty()) {
- CHECK_EQ(value, result);
+ CHECK(value->Equals(context_, result.ToLocalChecked()).FromJust());
}
} else {
CHECK(expectations == EXPECT_EXCEPTION);
CHECK(catcher.HasCaught());
if (!value.IsEmpty()) {
- CHECK_EQ(value, catcher.Exception());
+ CHECK(value->Equals(context_, catcher.Exception()).FromJust());
}
}
}
@@ -598,6 +612,7 @@
TEST(CrossScriptReferences) {
+ i::FLAG_legacy_const = true;
v8::Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
@@ -637,7 +652,6 @@
TEST(CrossScriptReferences_Simple) {
- i::FLAG_harmony_scoping = true;
i::FLAG_use_strict = true;
v8::Isolate* isolate = CcTest::isolate();
@@ -652,7 +666,6 @@
TEST(CrossScriptReferences_Simple2) {
- i::FLAG_harmony_scoping = true;
i::FLAG_use_strict = true;
v8::Isolate* isolate = CcTest::isolate();
@@ -675,9 +688,6 @@
TEST(CrossScriptReferencesHarmony) {
- i::FLAG_harmony_scoping = true;
- i::FLAG_harmony_modules = true;
-
v8::Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
@@ -687,7 +697,6 @@
"'use strict'; function x() { return 1 }; x()", "x()",
"'use strict'; let x = 1; x", "x",
"'use strict'; const x = 1; x", "x",
- "'use strict'; module x { export let a = 1 }; x.a", "x.a",
NULL
};
@@ -820,10 +829,27 @@
}
+TEST(CrossScriptReferencesHarmonyRegress) {
+ v8::Isolate* isolate = CcTest::isolate();
+ HandleScope scope(isolate);
+ SimpleContext context;
+ context.Check(
+ "'use strict';"
+ "function i1() { "
+ " let y = 10; return (typeof x2 === 'undefined' ? 0 : 2) + y"
+ "}"
+ "i1();"
+ "i1();",
+ EXPECT_RESULT, Number::New(isolate, 10));
+ context.Check(
+ "'use strict';"
+ "let x2 = 2; i1();",
+ EXPECT_RESULT, Number::New(isolate, 12));
+}
+
+
TEST(GlobalLexicalOSR) {
i::FLAG_use_strict = true;
- i::FLAG_harmony_scoping = true;
- i::FLAG_harmony_modules = true;
v8::Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
@@ -847,8 +873,6 @@
TEST(CrossScriptConflicts) {
i::FLAG_use_strict = true;
- i::FLAG_harmony_scoping = true;
- i::FLAG_harmony_modules = true;
HandleScope scope(CcTest::isolate());
@@ -857,7 +881,6 @@
"function x() { return 1 }; x()",
"let x = 1; x",
"const x = 1; x",
- "module x { export let a = 1 }; x.a",
NULL
};
const char* seconds[] = {
@@ -865,7 +888,6 @@
"function x() { return 2 }; x()",
"let x = 2; x",
"const x = 2; x",
- "module x { export let a = 2 }; x.a",
NULL
};
@@ -886,16 +908,18 @@
TEST(CrossScriptDynamicLookup) {
- i::FLAG_harmony_scoping = true;
-
HandleScope handle_scope(CcTest::isolate());
{
SimpleContext context;
- Local<String> undefined_string = String::NewFromUtf8(
- CcTest::isolate(), "undefined", String::kInternalizedString);
- Local<String> number_string = String::NewFromUtf8(
- CcTest::isolate(), "number", String::kInternalizedString);
+ Local<String> undefined_string =
+ String::NewFromUtf8(CcTest::isolate(), "undefined",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> number_string =
+ String::NewFromUtf8(CcTest::isolate(), "number",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
context.Check(
"function f(o) { with(o) { return x; } }"
@@ -919,8 +943,6 @@
TEST(CrossScriptGlobal) {
- i::FLAG_harmony_scoping = true;
-
HandleScope handle_scope(CcTest::isolate());
{
SimpleContext context;
@@ -963,16 +985,18 @@
TEST(CrossScriptStaticLookupUndeclared) {
- i::FLAG_harmony_scoping = true;
-
HandleScope handle_scope(CcTest::isolate());
{
SimpleContext context;
- Local<String> undefined_string = String::NewFromUtf8(
- CcTest::isolate(), "undefined", String::kInternalizedString);
- Local<String> number_string = String::NewFromUtf8(
- CcTest::isolate(), "number", String::kInternalizedString);
+ Local<String> undefined_string =
+ String::NewFromUtf8(CcTest::isolate(), "undefined",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ Local<String> number_string =
+ String::NewFromUtf8(CcTest::isolate(), "number",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
context.Check(
"function f(o) { return x; }"
@@ -997,7 +1021,6 @@
TEST(CrossScriptLoadICs) {
- i::FLAG_harmony_scoping = true;
i::FLAG_allow_natives_syntax = true;
HandleScope handle_scope(CcTest::isolate());
@@ -1053,7 +1076,6 @@
TEST(CrossScriptStoreICs) {
- i::FLAG_harmony_scoping = true;
i::FLAG_allow_natives_syntax = true;
HandleScope handle_scope(CcTest::isolate());
@@ -1131,7 +1153,6 @@
TEST(CrossScriptAssignmentToConst) {
- i::FLAG_harmony_scoping = true;
i::FLAG_allow_natives_syntax = true;
HandleScope handle_scope(CcTest::isolate());
@@ -1151,3 +1172,102 @@
context.Check("x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
}
}
+
+
+TEST(Regress425510) {
+ i::FLAG_allow_natives_syntax = true;
+
+ HandleScope handle_scope(CcTest::isolate());
+
+ {
+ SimpleContext context;
+
+ context.Check("'use strict'; o; const o = 10", EXPECT_EXCEPTION);
+
+ for (int i = 0; i < 100; i++) {
+ context.Check("o.prototype", EXPECT_EXCEPTION);
+ }
+ }
+}
+
+
+TEST(Regress3941) {
+ i::FLAG_allow_natives_syntax = true;
+
+ HandleScope handle_scope(CcTest::isolate());
+
+ {
+ SimpleContext context;
+ context.Check("function f() { x = 1; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Train ICs.
+ SimpleContext context;
+ context.Check("function f() { x = 1; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f(); x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
+ }
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Optimize.
+ SimpleContext context;
+ context.Check("function f() { x = 1; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f(); x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
+ }
+ context.Check("%OptimizeFunctionOnNextCall(f); f(); x", EXPECT_RESULT,
+ Number::New(CcTest::isolate(), 1));
+
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+}
+
+
+TEST(Regress3941_Reads) {
+ i::FLAG_allow_natives_syntax = true;
+
+ HandleScope handle_scope(CcTest::isolate());
+
+ {
+ SimpleContext context;
+ context.Check("function f() { return x; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Train ICs.
+ SimpleContext context;
+ context.Check("function f() { return x; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f()", EXPECT_EXCEPTION);
+ }
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+
+
+ {
+ // Optimize.
+ SimpleContext context;
+ context.Check("function f() { return x; }", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+ for (int i = 0; i < 4; i++) {
+ context.Check("f()", EXPECT_EXCEPTION);
+ }
+ context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT,
+ Undefined(CcTest::isolate()));
+
+ context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION);
+ }
+}