Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Upgrade V8 to 3.6.6.14
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Dec 15, 2011
1 parent 2255efa commit de3c16a
Show file tree
Hide file tree
Showing 14 changed files with 383 additions and 79 deletions.
57 changes: 32 additions & 25 deletions deps/v8/src/api.cc
Expand Up @@ -1456,31 +1456,35 @@ Local<Script> Script::New(v8::Handle<String> source,
ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>());
LOG_API(isolate, "Script::New");
ENTER_V8(isolate);
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Handle<i::Object> name_obj;
int line_offset = 0;
int column_offset = 0;
if (origin != NULL) {
if (!origin->ResourceName().IsEmpty()) {
name_obj = Utils::OpenHandle(*origin->ResourceName());
}
if (!origin->ResourceLineOffset().IsEmpty()) {
line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
i::SharedFunctionInfo* raw_result = NULL;
{ i::HandleScope scope(isolate);
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Handle<i::Object> name_obj;
int line_offset = 0;
int column_offset = 0;
if (origin != NULL) {
if (!origin->ResourceName().IsEmpty()) {
name_obj = Utils::OpenHandle(*origin->ResourceName());
}
if (!origin->ResourceLineOffset().IsEmpty()) {
line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
}
if (!origin->ResourceColumnOffset().IsEmpty()) {
column_offset =
static_cast<int>(origin->ResourceColumnOffset()->Value());
}
}
if (!origin->ResourceColumnOffset().IsEmpty()) {
column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value());
EXCEPTION_PREAMBLE(isolate);
i::ScriptDataImpl* pre_data_impl =
static_cast<i::ScriptDataImpl*>(pre_data);
// We assert that the pre-data is sane, even though we can actually
// handle it if it turns out not to be in release mode.
ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
// If the pre-data isn't sane we simply ignore it
if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
pre_data_impl = NULL;
}
}
EXCEPTION_PREAMBLE(isolate);
i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data);
// We assert that the pre-data is sane, even though we can actually
// handle it if it turns out not to be in release mode.
ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
// If the pre-data isn't sane we simply ignore it
if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
pre_data_impl = NULL;
}
i::Handle<i::SharedFunctionInfo> result =
i::Handle<i::SharedFunctionInfo> result =
i::Compiler::Compile(str,
name_obj,
line_offset,
Expand All @@ -1489,8 +1493,11 @@ Local<Script> Script::New(v8::Handle<String> source,
pre_data_impl,
Utils::OpenHandle(*script_data),
i::NOT_NATIVES_CODE);
has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
raw_result = *result;
}
i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
return Local<Script>(ToApi<Script>(result));
}

Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/arm/lithium-codegen-arm.cc
Expand Up @@ -2992,11 +2992,11 @@ void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
__ and_(scratch, result, Operand(HeapNumber::kSignMask));

__ Vmov(double_scratch0(), 0.5);
__ vadd(input, input, double_scratch0());
__ vadd(double_scratch0(), input, double_scratch0());

// Check sign of the result: if the sign changed, the input
// value was in ]0.5, 0[ and the result should be -0.
__ vmov(result, input.high());
__ vmov(result, double_scratch0().high());
__ eor(result, result, Operand(scratch), SetCC);
if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
DeoptimizeIf(mi, instr->environment());
Expand All @@ -3007,7 +3007,7 @@ void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {

__ EmitVFPTruncate(kRoundToMinusInf,
double_scratch0().low(),
input,
double_scratch0(),
result,
scratch);
DeoptimizeIf(ne, instr->environment());
Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/ia32/lithium-codegen-ia32.cc
Expand Up @@ -2770,12 +2770,12 @@ void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
__ movdbl(xmm_scratch, Operand::StaticVariable(one_half));
__ ucomisd(xmm_scratch, input_reg);
__ j(above, &below_half);
// input = input + 0.5
__ addsd(input_reg, xmm_scratch);
// xmm_scratch = input + 0.5
__ addsd(xmm_scratch, input_reg);

// Compute Math.floor(value + 0.5).
// Use truncating instruction (OK because input is positive).
__ cvttsd2si(output_reg, Operand(input_reg));
__ cvttsd2si(output_reg, Operand(xmm_scratch));

// Overflow is signalled with minint.
__ cmp(output_reg, 0x80000000u);
Expand Down
73 changes: 49 additions & 24 deletions deps/v8/src/mark-compact.cc
Expand Up @@ -665,13 +665,19 @@ class StaticMarkingVisitor : public StaticVisitorBase {
}

// Only flush code for functions.
if (shared_info->code()->kind() != Code::FUNCTION) return false;
if (shared_info->code()->kind() != Code::FUNCTION) {
return false;
}

// Function must be lazy compilable.
if (!shared_info->allows_lazy_compilation()) return false;
if (!shared_info->allows_lazy_compilation()) {
return false;
}

// If this is a full script wrapped in a function we do no flush the code.
if (shared_info->is_toplevel()) return false;
if (shared_info->is_toplevel()) {
return false;
}

// Age this shared function info.
if (shared_info->code_age() < kCodeAgeThreshold) {
Expand Down Expand Up @@ -864,21 +870,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
collector->MarkObject(jsfunction->unchecked_shared()->unchecked_code());

if (jsfunction->unchecked_code()->kind() == Code::OPTIMIZED_FUNCTION) {
// For optimized functions we should retain both non-optimized version
// of it's code and non-optimized version of all inlined functions.
// This is required to support bailing out from inlined code.
DeoptimizationInputData* data =
reinterpret_cast<DeoptimizationInputData*>(
jsfunction->unchecked_code()->unchecked_deoptimization_data());

FixedArray* literals = data->UncheckedLiteralArray();

for (int i = 0, count = data->InlinedFunctionCount()->value();
i < count;
i++) {
JSFunction* inlined = reinterpret_cast<JSFunction*>(literals->get(i));
collector->MarkObject(inlined->unchecked_shared()->unchecked_code());
}
collector->MarkInlinedFunctionsCode(jsfunction->unchecked_code());
}
}

Expand Down Expand Up @@ -994,9 +986,7 @@ class CodeMarkingVisitor : public ThreadVisitor {
: collector_(collector) {}

void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
for (StackFrameIterator it(isolate, top); !it.done(); it.Advance()) {
collector_->MarkObject(it.frame()->unchecked_code());
}
collector_->PrepareThreadForCodeFlushing(isolate, top);
}

private:
Expand Down Expand Up @@ -1027,6 +1017,42 @@ class SharedFunctionInfoMarkingVisitor : public ObjectVisitor {
};


void MarkCompactCollector::MarkInlinedFunctionsCode(Code* code) {
// For optimized functions we should retain both non-optimized version
// of it's code and non-optimized version of all inlined functions.
// This is required to support bailing out from inlined code.
DeoptimizationInputData* data =
reinterpret_cast<DeoptimizationInputData*>(
code->unchecked_deoptimization_data());

FixedArray* literals = data->UncheckedLiteralArray();

for (int i = 0, count = data->InlinedFunctionCount()->value();
i < count;
i++) {
JSFunction* inlined = reinterpret_cast<JSFunction*>(literals->get(i));
MarkObject(inlined->unchecked_shared()->unchecked_code());
}
}


void MarkCompactCollector::PrepareThreadForCodeFlushing(Isolate* isolate,
ThreadLocalTop* top) {
for (StackFrameIterator it(isolate, top); !it.done(); it.Advance()) {
// Note: for the frame that has a pending lazy deoptimization
// StackFrame::unchecked_code will return a non-optimized code object for
// the outermost function and StackFrame::LookupCode will return
// actual optimized code object.
StackFrame* frame = it.frame();
Code* code = frame->unchecked_code();
MarkObject(code);
if (frame->is_optimized()) {
MarkInlinedFunctionsCode(frame->LookupCode());
}
}
}


void MarkCompactCollector::PrepareForCodeFlushing() {
ASSERT(heap() == Isolate::Current()->heap());

Expand All @@ -1050,9 +1076,8 @@ void MarkCompactCollector::PrepareForCodeFlushing() {

// Make sure we are not referencing the code from the stack.
ASSERT(this == heap()->mark_compact_collector());
for (StackFrameIterator it; !it.done(); it.Advance()) {
MarkObject(it.frame()->unchecked_code());
}
PrepareThreadForCodeFlushing(heap()->isolate(),
heap()->isolate()->thread_local_top());

// Iterate the archived stacks in all threads to check if
// the code is referenced.
Expand Down
12 changes: 12 additions & 0 deletions deps/v8/src/mark-compact.h
Expand Up @@ -96,6 +96,10 @@ class MarkingStack {
};


// Defined in isolate.h.
class ThreadLocalTop;


// -------------------------------------------------------------------------
// Mark-Compact collector

Expand Down Expand Up @@ -253,6 +257,14 @@ class MarkCompactCollector {
friend class CodeMarkingVisitor;
friend class SharedFunctionInfoMarkingVisitor;

// Mark non-optimize code for functions inlined into the given optimized
// code. This will prevent it from being flushed.
void MarkInlinedFunctionsCode(Code* code);

// Mark code objects that are active on the stack to prevent them
// from being flushed.
void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top);

void PrepareForCodeFlushing();

// Marking operations for objects reachable from roots.
Expand Down
28 changes: 15 additions & 13 deletions deps/v8/src/parser.cc
Expand Up @@ -2036,6 +2036,20 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
// reported (underlining).
Expect(Token::RETURN, CHECK_OK);

Token::Value tok = peek();
Statement* result;
if (scanner().HasAnyLineTerminatorBeforeNext() ||
tok == Token::SEMICOLON ||
tok == Token::RBRACE ||
tok == Token::EOS) {
ExpectSemicolon(CHECK_OK);
result = new(zone()) ReturnStatement(GetLiteralUndefined());
} else {
Expression* expr = ParseExpression(true, CHECK_OK);
ExpectSemicolon(CHECK_OK);
result = new(zone()) ReturnStatement(expr);
}

// An ECMAScript program is considered syntactically incorrect if it
// contains a return statement that is not within the body of a
// function. See ECMA-262, section 12.9, page 67.
Expand All @@ -2048,19 +2062,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
Expression* throw_error = NewThrowSyntaxError(type, Handle<Object>::null());
return new(zone()) ExpressionStatement(throw_error);
}

Token::Value tok = peek();
if (scanner().HasAnyLineTerminatorBeforeNext() ||
tok == Token::SEMICOLON ||
tok == Token::RBRACE ||
tok == Token::EOS) {
ExpectSemicolon(CHECK_OK);
return new(zone()) ReturnStatement(GetLiteralUndefined());
}

Expression* expr = ParseExpression(true, CHECK_OK);
ExpectSemicolon(CHECK_OK);
return new(zone()) ReturnStatement(expr);
return result;
}


Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/preparser.cc
Expand Up @@ -540,6 +540,7 @@ PreParser::Statement PreParser::ParseDoWhileStatement(bool* ok) {
Expect(i::Token::LPAREN, CHECK_OK);
ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, ok);
if (peek() == i::Token::SEMICOLON) Consume(i::Token::SEMICOLON);
return Statement::Default();
}

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/v8threads.h
Expand Up @@ -72,7 +72,7 @@ class ThreadState {
};


// Defined in top.h
// Defined in isolate.h.
class ThreadLocalTop;


Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/version.cc
Expand Up @@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 6
#define BUILD_NUMBER 6
#define PATCH_LEVEL 11
#define PATCH_LEVEL 14
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/x64/lithium-codegen-x64.cc
Expand Up @@ -2773,10 +2773,10 @@ void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
// This addition might give a result that isn't the correct for
// rounding, due to loss of precision, but only for a number that's
// so big that the conversion below will overflow anyway.
__ addsd(input_reg, xmm_scratch);
__ addsd(xmm_scratch, input_reg);
// Compute Math.floor(input).
// Use truncating instruction (OK because input is positive).
__ cvttsd2si(output_reg, input_reg);
__ cvttsd2si(output_reg, xmm_scratch);
// Overflow is signalled with minint.
__ cmpl(output_reg, Immediate(0x80000000));
DeoptimizeIf(equal, instr->environment());
Expand Down

0 comments on commit de3c16a

Please sign in to comment.