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/compiler/function-tester.h b/test/cctest/compiler/function-tester.h
index 7e16eea..2fcd353 100644
--- a/test/cctest/compiler/function-tester.h
+++ b/test/cctest/compiler/function-tester.h
@@ -5,22 +5,18 @@
#ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
#define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
-#include "src/v8.h"
-#include "test/cctest/cctest.h"
-
-#include "src/ast-numbering.h"
+#include "src/ast/ast-numbering.h"
+#include "src/ast/scopes.h"
#include "src/compiler.h"
#include "src/compiler/linkage.h"
#include "src/compiler/pipeline.h"
#include "src/execution.h"
-#include "src/full-codegen.h"
+#include "src/full-codegen/full-codegen.h"
#include "src/handles.h"
#include "src/objects-inl.h"
-#include "src/parser.h"
-#include "src/rewriter.h"
-#include "src/scopes.h"
-
-#define USE_CRANKSHAFT 0
+#include "src/parsing/parser.h"
+#include "src/parsing/rewriter.h"
+#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
@@ -33,48 +29,65 @@
function((FLAG_allow_natives_syntax = true, NewFunction(source))),
flags_(flags) {
Compile(function);
- const uint32_t supported_flags = CompilationInfo::kContextSpecializing |
- CompilationInfo::kInliningEnabled |
- CompilationInfo::kTypingEnabled;
- CHECK_EQ(0, flags_ & ~supported_flags);
+ const uint32_t supported_flags =
+ CompilationInfo::kFunctionContextSpecializing |
+ CompilationInfo::kInliningEnabled | CompilationInfo::kTypingEnabled;
+ CHECK_EQ(0u, flags_ & ~supported_flags);
}
- explicit FunctionTester(Graph* graph)
+ FunctionTester(Graph* graph, int param_count)
: isolate(main_isolate()),
- function(NewFunction("(function(a,b){})")),
+ function(NewFunction(BuildFunction(param_count).c_str())),
flags_(0) {
CompileGraph(graph);
}
+ FunctionTester(const CallInterfaceDescriptor& descriptor, Handle<Code> code)
+ : isolate(main_isolate()),
+ function(
+ (FLAG_allow_natives_syntax = true,
+ NewFunction(BuildFunctionFromDescriptor(descriptor).c_str()))),
+ flags_(0) {
+ Compile(function);
+ function->ReplaceCode(*code);
+ }
+
Isolate* isolate;
Handle<JSFunction> function;
+ MaybeHandle<Object> Call() {
+ return Execution::Call(isolate, function, undefined(), 0, nullptr);
+ }
+
MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) {
Handle<Object> args[] = {a, b};
- return Execution::Call(isolate, function, undefined(), 2, args, false);
+ return Execution::Call(isolate, function, undefined(), 2, args);
+ }
+
+ MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c,
+ Handle<Object> d) {
+ Handle<Object> args[] = {a, b, c, d};
+ return Execution::Call(isolate, function, undefined(), 4, args);
}
void CheckThrows(Handle<Object> a, Handle<Object> b) {
- TryCatch try_catch;
+ TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a, b);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
CHECK(no_result.is_null());
- // TODO(mstarzinger): Temporary workaround for issue chromium:362388.
isolate->OptionalRescheduleException(true);
}
- v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a,
- Handle<Object> b) {
- TryCatch try_catch;
+ v8::Local<v8::Message> CheckThrowsReturnMessage(Handle<Object> a,
+ Handle<Object> b) {
+ TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
MaybeHandle<Object> no_result = Call(a, b);
CHECK(isolate->has_pending_exception());
CHECK(try_catch.HasCaught());
CHECK(no_result.is_null());
- // TODO(mstarzinger): Calling OptionalRescheduleException is a dirty hack,
- // it's the only way to make Message() not to assert because an external
- // exception has been caught by the try_catch.
isolate->OptionalRescheduleException(true);
+ CHECK(!try_catch.Message().IsEmpty());
return try_catch.Message();
}
@@ -118,13 +131,13 @@
}
Handle<JSFunction> NewFunction(const char* source) {
- return v8::Utils::OpenHandle(
- *v8::Handle<v8::Function>::Cast(CompileRun(source)));
+ return Handle<JSFunction>::cast(v8::Utils::OpenHandle(
+ *v8::Local<v8::Function>::Cast(CompileRun(source))));
}
Handle<JSObject> NewObject(const char* source) {
- return v8::Utils::OpenHandle(
- *v8::Handle<v8::Object>::Cast(CompileRun(source)));
+ return Handle<JSObject>::cast(v8::Utils::OpenHandle(
+ *v8::Local<v8::Object>::Cast(CompileRun(source))));
}
Handle<String> Val(const char* string) {
@@ -151,13 +164,15 @@
Handle<JSFunction> Compile(Handle<JSFunction> function) {
// TODO(titzer): make this method private.
-#if V8_TURBOFAN_TARGET
- CompilationInfoWithZone info(function);
+ Zone zone;
+ ParseInfo parse_info(&zone, function);
+ CompilationInfo info(&parse_info);
+ info.MarkAsDeoptimizationEnabled();
- CHECK(Parser::Parse(&info));
+ CHECK(Parser::ParseStatic(info.parse_info()));
info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
- if (flags_ & CompilationInfo::kContextSpecializing) {
- info.MarkAsContextSpecializing();
+ if (flags_ & CompilationInfo::kFunctionContextSpecializing) {
+ info.MarkAsFunctionContextSpecializing();
}
if (flags_ & CompilationInfo::kInliningEnabled) {
info.MarkAsInliningEnabled();
@@ -165,37 +180,22 @@
if (flags_ & CompilationInfo::kTypingEnabled) {
info.MarkAsTypingEnabled();
}
- CHECK(Compiler::Analyze(&info));
+ CHECK(Compiler::Analyze(info.parse_info()));
CHECK(Compiler::EnsureDeoptimizationSupport(&info));
Pipeline pipeline(&info);
Handle<Code> code = pipeline.GenerateCode();
- if (FLAG_turbo_deoptimization) {
- info.context()->native_context()->AddOptimizedCode(*code);
- }
-
CHECK(!code.is_null());
+ info.dependencies()->Commit(code);
+ info.context()->native_context()->AddOptimizedCode(*code);
function->ReplaceCode(*code);
-#elif USE_CRANKSHAFT
- Handle<Code> unoptimized = Handle<Code>(function->code());
- Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized,
- Compiler::NOT_CONCURRENT);
- CHECK(!code.is_null());
-#if ENABLE_DISASSEMBLER
- if (FLAG_print_opt_code) {
- CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
- code->Disassemble("test code", tracing_scope.file());
- }
-#endif
- function->ReplaceCode(*code);
-#endif
return function;
}
- static Handle<JSFunction> ForMachineGraph(Graph* graph) {
+ static Handle<JSFunction> ForMachineGraph(Graph* graph, int param_count) {
JSFunction* p = NULL;
{ // because of the implicit handle scope of FunctionTester.
- FunctionTester f(graph);
+ FunctionTester f(graph, param_count);
p = *f.function;
}
return Handle<JSFunction>(p); // allocated in outer handle scope.
@@ -204,16 +204,36 @@
private:
uint32_t flags_;
+ std::string BuildFunction(int param_count) {
+ std::string function_string = "(function(";
+ if (param_count > 0) {
+ char next = 'a';
+ function_string += next;
+ while (param_count-- > 0) {
+ function_string += ',';
+ function_string += ++next;
+ }
+ }
+ function_string += "){})";
+ return function_string;
+ }
+
+ std::string BuildFunctionFromDescriptor(
+ const CallInterfaceDescriptor& descriptor) {
+ return BuildFunction(descriptor.GetParameterCount());
+ }
+
// Compile the given machine graph instead of the source of the function
// and replace the JSFunction's code with the result.
Handle<JSFunction> CompileGraph(Graph* graph) {
- CHECK(Pipeline::SupportedTarget());
- CompilationInfoWithZone info(function);
+ Zone zone;
+ ParseInfo parse_info(&zone, function);
+ CompilationInfo info(&parse_info);
- CHECK(Parser::Parse(&info));
+ CHECK(Parser::ParseStatic(info.parse_info()));
info.SetOptimizing(BailoutId::None(),
Handle<Code>(function->shared()->code()));
- CHECK(Compiler::Analyze(&info));
+ CHECK(Compiler::Analyze(info.parse_info()));
CHECK(Compiler::EnsureDeoptimizationSupport(&info));
Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph);
@@ -222,8 +242,8 @@
return function;
}
};
-}
-}
-} // namespace v8::internal::compiler
+} // namespace compiler
+} // namespace internal
+} // namespace v8
#endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_