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/src/codegen.cc b/src/codegen.cc
index 627e836..a57cbb3 100644
--- a/src/codegen.cc
+++ b/src/codegen.cc
@@ -2,39 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/v8.h"
-
-#include "src/bootstrapper.h"
#include "src/codegen.h"
+
+#if defined(V8_OS_AIX)
+#include <fenv.h> // NOLINT(build/c++11)
+#endif
+#include "src/ast/prettyprinter.h"
+#include "src/bootstrapper.h"
#include "src/compiler.h"
-#include "src/cpu-profiler.h"
-#include "src/debug.h"
-#include "src/prettyprinter.h"
-#include "src/rewriter.h"
+#include "src/debug/debug.h"
+#include "src/parsing/parser.h"
+#include "src/profiler/cpu-profiler.h"
#include "src/runtime/runtime.h"
namespace v8 {
namespace internal {
-#if defined(_WIN64)
-typedef double (*ModuloFunction)(double, double);
-static ModuloFunction modulo_function = NULL;
-// Defined in codegen-x64.cc.
-ModuloFunction CreateModuloFunction();
-
-void init_modulo_function() {
- modulo_function = CreateModuloFunction();
-}
-
-
-double modulo(double x, double y) {
- // Note: here we rely on dependent reads being ordered. This is true
- // on all architectures we currently support.
- return (*modulo_function)(x, y);
-}
-#elif defined(_WIN32)
-
+#if defined(V8_OS_WIN)
double modulo(double x, double y) {
// Workaround MS fmod bugs. ECMA-262 says:
// dividend is finite and divisor is an infinity => result equals dividend
@@ -48,33 +33,39 @@
#else // POSIX
double modulo(double x, double y) {
+#if defined(V8_OS_AIX)
+ // AIX raises an underflow exception for (Number.MIN_VALUE % Number.MAX_VALUE)
+ feclearexcept(FE_ALL_EXCEPT);
+ double result = std::fmod(x, y);
+ int exception = fetestexcept(FE_UNDERFLOW);
+ return (exception ? x : result);
+#else
return std::fmod(x, y);
+#endif
}
-#endif // defined(_WIN64)
+#endif // defined(V8_OS_WIN)
-#define UNARY_MATH_FUNCTION(name, generator) \
-static UnaryMathFunction fast_##name##_function = NULL; \
-void init_fast_##name##_function() { \
- fast_##name##_function = generator; \
-} \
-double fast_##name(double x) { \
- return (*fast_##name##_function)(x); \
-}
+#define UNARY_MATH_FUNCTION(name, generator) \
+ static UnaryMathFunctionWithIsolate fast_##name##_function = nullptr; \
+ double std_##name(double x, Isolate* isolate) { return std::name(x); } \
+ void init_fast_##name##_function(Isolate* isolate) { \
+ if (FLAG_fast_math) fast_##name##_function = generator(isolate); \
+ if (!fast_##name##_function) fast_##name##_function = std_##name; \
+ } \
+ void lazily_initialize_fast_##name(Isolate* isolate) { \
+ if (!fast_##name##_function) init_fast_##name##_function(isolate); \
+ } \
+ double fast_##name(double x, Isolate* isolate) { \
+ return (*fast_##name##_function)(x, isolate); \
+ }
-UNARY_MATH_FUNCTION(exp, CreateExpFunction())
-UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
+UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction)
+UNARY_MATH_FUNCTION(exp, CreateExpFunction)
#undef UNARY_MATH_FUNCTION
-void lazily_initialize_fast_exp() {
- if (fast_exp_function == NULL) {
- init_fast_exp_function();
- }
-}
-
-
#define __ ACCESS_MASM(masm_)
#ifdef DEBUG
@@ -110,37 +101,39 @@
}
if (FLAG_trace_codegen || print_source || print_ast) {
- PrintF("[generating %s code for %s function: ", kind, ftype);
- if (info->IsStub()) {
- const char* name =
- CodeStub::MajorName(info->code_stub()->MajorKey(), true);
- PrintF("%s", name == NULL ? "<unknown>" : name);
- } else {
- AllowDeferredHandleDereference allow_deference_for_trace;
- PrintF("%s", info->function()->debug_name()->ToCString().get());
- }
- PrintF("]\n");
+ base::SmartArrayPointer<char> name = info->GetDebugName();
+ PrintF("[generating %s code for %s function: %s]\n", kind, ftype,
+ name.get());
}
#ifdef DEBUG
- if (!info->IsStub() && print_source) {
+ if (info->parse_info() && print_source) {
PrintF("--- Source from AST ---\n%s\n",
- PrettyPrinter(info->zone()).PrintProgram(info->function()));
+ PrettyPrinter(info->isolate()).PrintProgram(info->literal()));
}
- if (!info->IsStub() && print_ast) {
+ if (info->parse_info() && print_ast) {
PrintF("--- AST ---\n%s\n",
- AstPrinter(info->zone()).PrintProgram(info->function()));
+ AstPrinter(info->isolate()).PrintProgram(info->literal()));
}
#endif // DEBUG
}
Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
- Code::Flags flags,
CompilationInfo* info) {
Isolate* isolate = info->isolate();
+ Code::Flags flags;
+ if (info->IsStub() && info->code_stub()) {
+ DCHECK_EQ(info->output_code_kind(), info->code_stub()->GetCodeKind());
+ flags = Code::ComputeFlags(
+ info->output_code_kind(), info->code_stub()->GetICState(),
+ info->code_stub()->GetExtraICState(), info->code_stub()->GetStubType());
+ } else {
+ flags = Code::ComputeFlags(info->output_code_kind());
+ }
+
// Allocate and install the code.
CodeDesc desc;
bool is_crankshafted =
@@ -169,23 +162,25 @@
(info->IsStub() && FLAG_print_code_stubs) ||
(info->IsOptimizing() && FLAG_print_opt_code));
if (print_code) {
- // Print the source code if available.
- FunctionLiteral* function = info->function();
- bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION ||
- code->kind() == Code::FUNCTION;
-
+ base::SmartArrayPointer<char> debug_name = info->GetDebugName();
CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
+
+ // Print the source code if available.
+ bool print_source =
+ info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION ||
+ code->kind() == Code::FUNCTION);
if (print_source) {
+ FunctionLiteral* literal = info->literal();
Handle<Script> script = info->script();
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
os << "--- Raw source ---\n";
StringCharacterStream stream(String::cast(script->source()),
- function->start_position());
+ literal->start_position());
// fun->end_position() points to the last character in the stream. We
// need to compensate by adding one to calculate the length.
int source_len =
- function->end_position() - function->start_position() + 1;
+ literal->end_position() - literal->start_position() + 1;
for (int i = 0; i < source_len; i++) {
if (stream.HasMore()) {
os << AsReversiblyEscapedUC16(stream.GetNext());
@@ -195,10 +190,9 @@
}
}
if (info->IsOptimizing()) {
- if (FLAG_print_unopt_code) {
+ if (FLAG_print_unopt_code && info->parse_info()) {
os << "--- Unoptimized code ---\n";
- info->closure()->shared()->code()->Disassemble(
- function->debug_name()->ToCString().get(), os);
+ info->closure()->shared()->code()->Disassemble(debug_name.get(), os);
}
os << "--- Optimized code ---\n"
<< "optimization_id = " << info->optimization_id() << "\n";
@@ -206,31 +200,14 @@
os << "--- Code ---\n";
}
if (print_source) {
- os << "source_position = " << function->start_position() << "\n";
+ FunctionLiteral* literal = info->literal();
+ os << "source_position = " << literal->start_position() << "\n";
}
- if (info->IsStub()) {
- CodeStub::Major major_key = info->code_stub()->MajorKey();
- code->Disassemble(CodeStub::MajorName(major_key, false), os);
- } else {
- code->Disassemble(function->debug_name()->ToCString().get(), os);
- }
+ code->Disassemble(debug_name.get(), os);
os << "--- End code ---\n";
}
#endif // ENABLE_DISASSEMBLER
}
-
-bool CodeGenerator::RecordPositions(MacroAssembler* masm,
- int pos,
- bool right_here) {
- if (pos != RelocInfo::kNoPosition) {
- masm->positions_recorder()->RecordStatementPosition(pos);
- masm->positions_recorder()->RecordPosition(pos);
- if (right_here) {
- return masm->positions_recorder()->WriteRecordedPositions();
- }
- }
- return false;
-}
-
-} } // namespace v8::internal
+} // namespace internal
+} // namespace v8