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

Commit

Permalink
V8: Upgrade to 3.14.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Mar 6, 2013
1 parent d258fb0 commit 81c278d
Show file tree
Hide file tree
Showing 37 changed files with 479 additions and 154 deletions.
1 change: 1 addition & 0 deletions deps/v8/AUTHORS
Expand Up @@ -20,6 +20,7 @@ Burcu Dogan <burcujdogan@gmail.com>
Craig Schlenter <craig.schlenter@gmail.com>
Daniel Andersson <kodandersson@gmail.com>
Daniel James <dnljms@gmail.com>
Derek J Conrod <dconrod@codeaurora.org>
Dineel D Sule <dsule@codeaurora.org>
Erich Ocean <erich.ocean@me.com>
Fedor Indutny <fedor@indutny.com>
Expand Down
11 changes: 10 additions & 1 deletion deps/v8/build/common.gypi
Expand Up @@ -157,7 +157,7 @@
[ 'v8_use_arm_eabi_hardfloat=="true"', {
'defines': [
'USE_EABI_HARDFLOAT=1',
'CAN_USE_VFP2_INSTRUCTIONS',
'CAN_USE_VFP3_INSTRUCTIONS',
],
'target_conditions': [
['_toolset=="target"', {
Expand Down Expand Up @@ -378,6 +378,15 @@
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
or OS=="android"', {
'cflags!': [
'-O2',
'-Os',
],
'cflags': [
'-fdata-sections',
'-ffunction-sections',
'-O3',
],
'conditions': [
[ 'gcc_version==44 and clang==0', {
'cflags': [
Expand Down
6 changes: 5 additions & 1 deletion deps/v8/include/v8.h
Expand Up @@ -3102,8 +3102,12 @@ class V8EXPORT V8 {
*
* The same message listener can be added more than once and in that
* case it will be called more than once for each message.
*
* If data is specified, it will be passed to the callback when it is called.
* Otherwise, the exception object will be passed to the callback instead.
*/
static bool AddMessageListener(MessageCallback that);
static bool AddMessageListener(MessageCallback that,
Handle<Value> data = Handle<Value>());

/**
* Remove all message listeners from the specified callback function.
Expand Down
11 changes: 8 additions & 3 deletions deps/v8/src/api.cc
Expand Up @@ -5270,14 +5270,18 @@ void V8::IgnoreOutOfMemoryException() {
}


bool V8::AddMessageListener(MessageCallback that) {
bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
i::Isolate* isolate = i::Isolate::Current();
EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
NeanderArray listeners(isolate->factory()->message_listeners());
listeners.add(isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
NeanderObject obj(2);
obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
: *Utils::OpenHandle(*data));
listeners.add(obj.value());
return true;
}

Expand All @@ -5292,7 +5296,8 @@ void V8::RemoveMessageListeners(MessageCallback that) {
for (int i = 0; i < listeners.length(); i++) {
if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones

i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listeners.get(i)));
NeanderObject listener(i::JSObject::cast(listeners.get(i)));
i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
listeners.set(i, isolate->heap()->undefined_value());
}
Expand Down
7 changes: 6 additions & 1 deletion deps/v8/src/arm/stub-cache-arm.cc
Expand Up @@ -3467,7 +3467,13 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(
// r1: constructor function
// r2: initial map
// r7: undefined
ASSERT(function->has_initial_map());
__ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset));
#ifdef DEBUG
int instance_size = function->initial_map()->instance_size();
__ cmp(r3, Operand(instance_size >> kPointerSizeLog2));
__ Check(eq, "Instance size of initial map changed.");
#endif
__ AllocateInNewSpace(r3, r4, r5, r6, &generic_stub_call, SIZE_IN_WORDS);

// Allocated the JSObject, now initialize the fields. Map is set to initial
Expand Down Expand Up @@ -3525,7 +3531,6 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(
}

// Fill the unused in-object property fields with undefined.
ASSERT(function->has_initial_map());
for (int i = shared->this_property_assignments_count();
i < function->initial_map()->inobject_properties();
i++) {
Expand Down
6 changes: 5 additions & 1 deletion deps/v8/src/contexts.h
Expand Up @@ -344,9 +344,13 @@ class Context: public FixedArray {
// Compute the native context by traversing the context chain.
Context* native_context();

// Predicates for context types. IsNativeContext is defined on Object
// Predicates for context types. IsNativeContext is also defined on Object
// because we frequently have to know if arbitrary objects are natives
// contexts.
bool IsNativeContext() {
Map* map = this->map();
return map == map->GetHeap()->native_context_map();
}
bool IsFunctionContext() {
Map* map = this->map();
return map == map->GetHeap()->function_context_map();
Expand Down
7 changes: 7 additions & 0 deletions deps/v8/src/hydrogen-instructions.cc
Expand Up @@ -725,6 +725,13 @@ void HClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
}


void HWrapReceiver::PrintDataTo(StringStream* stream) {
receiver()->PrintNameTo(stream);
stream->Add(" ");
function()->PrintNameTo(stream);
}


void HAccessArgumentsAt::PrintDataTo(StringStream* stream) {
arguments()->PrintNameTo(stream);
stream->Add("[");
Expand Down
3 changes: 3 additions & 0 deletions deps/v8/src/hydrogen-instructions.h
Expand Up @@ -2760,6 +2760,8 @@ class HWrapReceiver: public HTemplateInstruction<2> {

virtual HValue* Canonicalize();

virtual void PrintDataTo(StringStream* stream);

DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
};

Expand Down Expand Up @@ -4805,6 +4807,7 @@ class HStringAdd: public HBinaryOperation {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps);
SetGVNFlag(kChangesNewSpacePromotion);
}

virtual Representation RequiredInputRepresentation(int index) {
Expand Down
5 changes: 4 additions & 1 deletion deps/v8/src/hydrogen.cc
Expand Up @@ -7502,7 +7502,10 @@ bool HGraphBuilder::TryCallApply(Call* expr) {
return true;
} else {
// We are inside inlined function and we know exactly what is inside
// arguments object.
// arguments object. But we need to be able to materialize at deopt.
// TODO(mstarzinger): For now we just ensure arguments are pushed
// right after HEnterInlined, but we could be smarter about this.
EnsureArgumentsArePushedForAccess();
HValue* context = environment()->LookupContext();

HValue* wrapped_receiver =
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/ia32/code-stubs-ia32.cc
Expand Up @@ -3593,7 +3593,7 @@ void ArgumentsAccessStub::GenerateNewNonStrictFast(MacroAssembler* masm) {
__ bind(&runtime);
__ pop(eax); // Remove saved parameter count.
__ mov(Operand(esp, 1 * kPointerSize), ecx); // Patch argument count.
__ TailCallRuntime(Runtime::kNewStrictArgumentsFast, 3, 1);
__ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
}


Expand Down
14 changes: 9 additions & 5 deletions deps/v8/src/ia32/stub-cache-ia32.cc
Expand Up @@ -3421,6 +3421,7 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(
#endif

// Load the initial map and verify that it is in fact a map.
// edi: constructor
__ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi.
__ JumpIfSmi(ebx, &generic_stub_call);
Expand All @@ -3429,19 +3430,23 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(

#ifdef DEBUG
// Cannot construct functions this way.
// edi: constructor
// ebx: initial map
__ CmpInstanceType(ebx, JS_FUNCTION_TYPE);
__ Assert(not_equal, "Function constructed by construct stub.");
__ Check(not_equal, "Function constructed by construct stub.");
#endif

// Now allocate the JSObject on the heap by moving the new space allocation
// top forward.
// edi: constructor
// ebx: initial map
ASSERT(function->has_initial_map());
int instance_size = function->initial_map()->instance_size();
#ifdef DEBUG
__ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceSizeOffset));
__ shl(ecx, kPointerSizeLog2);
__ AllocateInNewSpace(ecx, edx, ecx, no_reg,
__ cmp(ecx, Immediate(instance_size));
__ Check(equal, "Instance size of initial map changed.");
#endif
__ AllocateInNewSpace(instance_size, edx, ecx, no_reg,
&generic_stub_call, NO_ALLOCATION_FLAGS);

// Allocated the JSObject, now initialize the fields and add the heap tag.
Expand Down Expand Up @@ -3501,7 +3506,6 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(
}

// Fill the unused in-object property fields with undefined.
ASSERT(function->has_initial_map());
for (int i = shared->this_property_assignments_count();
i < function->initial_map()->inobject_properties();
i++) {
Expand Down
81 changes: 50 additions & 31 deletions deps/v8/src/json-parser.h
Expand Up @@ -192,8 +192,10 @@ Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source,
AdvanceSkipWhitespace();
Handle<Object> result = ParseJsonValue();
if (result.is_null() || c0_ != kEndOfString) {
// Parse failed. Current character is the unexpected token.
// Some exception (for example stack overflow) is already pending.
if (isolate_->has_pending_exception()) return Handle<Object>::null();

// Parse failed. Current character is the unexpected token.
const char* message;
Factory* factory = this->factory();
Handle<JSArray> array;
Expand Down Expand Up @@ -244,6 +246,12 @@ Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source,
// Parse any JSON value.
template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() {
StackLimitCheck stack_check(isolate_);
if (stack_check.HasOverflowed()) {
isolate_->StackOverflow();
return Handle<Object>::null();
}

if (c0_ == '"') return ParseJsonString();
if ((c0_ >= '0' && c0_ <= '9') || c0_ == '-') return ParseJsonNumber();
if (c0_ == '{') return ParseJsonObject();
Expand Down Expand Up @@ -293,45 +301,56 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
Advance();

uint32_t index = 0;
while (c0_ >= '0' && c0_ <= '9') {
int d = c0_ - '0';
if (index > 429496729U - ((d > 5) ? 1 : 0)) break;
index = (index * 10) + d;
Advance();
}
if (c0_ >= '0' && c0_ <= '9') {
// Maybe an array index, try to parse it.
if (c0_ == '0') {
// With a leading zero, the string has to be "0" only to be an index.
Advance();
} else {
do {
int d = c0_ - '0';
if (index > 429496729U - ((d > 5) ? 1 : 0)) break;
index = (index * 10) + d;
Advance();
} while (c0_ >= '0' && c0_ <= '9');
}

if (position_ != start_position + 1 && c0_ == '"') {
AdvanceSkipWhitespace();
if (c0_ == '"') {
// Successfully parsed index, parse and store element.
AdvanceSkipWhitespace();

if (c0_ != ':') return ReportUnexpectedCharacter();
AdvanceSkipWhitespace();
Handle<Object> value = ParseJsonValue();
if (value.is_null()) return ReportUnexpectedCharacter();
if (c0_ != ':') return ReportUnexpectedCharacter();
AdvanceSkipWhitespace();
Handle<Object> value = ParseJsonValue();
if (value.is_null()) return ReportUnexpectedCharacter();

JSObject::SetOwnElement(json_object, index, value, kNonStrictMode);
} else {
position_ = start_position;
JSObject::SetOwnElement(json_object, index, value, kNonStrictMode);
continue;
}
// Not an index, fallback to the slow path.
}

position_ = start_position;
#ifdef DEBUG
c0_ = '"';
c0_ = '"';
#endif

Handle<String> key = ParseJsonSymbol();
if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();
Handle<String> key = ParseJsonSymbol();
if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();

AdvanceSkipWhitespace();
Handle<Object> value = ParseJsonValue();
if (value.is_null()) return ReportUnexpectedCharacter();
AdvanceSkipWhitespace();
Handle<Object> value = ParseJsonValue();
if (value.is_null()) return ReportUnexpectedCharacter();

if (key->Equals(isolate()->heap()->Proto_symbol())) {
prototype = value;
if (key->Equals(isolate()->heap()->Proto_symbol())) {
prototype = value;
} else {
if (JSObject::TryTransitionToField(json_object, key)) {
int index = json_object->LastAddedFieldIndex();
json_object->FastPropertyAtPut(index, *value);
} else {
if (JSObject::TryTransitionToField(json_object, key)) {
int index = json_object->LastAddedFieldIndex();
json_object->FastPropertyAtPut(index, *value);
} else {
JSObject::SetLocalPropertyIgnoreAttributes(
json_object, key, value, NONE);
}
JSObject::SetLocalPropertyIgnoreAttributes(
json_object, key, value, NONE);
}
}
} while (MatchSkipWhiteSpace(','));
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/lithium.h
Expand Up @@ -156,8 +156,8 @@ class LUnallocated: public LOperand {
};

static const int kMaxVirtualRegisters = 1 << kVirtualRegisterWidth;
static const int kMaxFixedIndex = (1 << kFixedIndexWidth) - 1;
static const int kMinFixedIndex = -(1 << kFixedIndexWidth);
static const int kMaxFixedIndex = (1 << (kFixedIndexWidth - 1)) - 1;
static const int kMinFixedIndex = -(1 << (kFixedIndexWidth - 1));

bool HasAnyPolicy() const {
return policy() == ANY;
Expand Down
10 changes: 7 additions & 3 deletions deps/v8/src/messages.cc
Expand Up @@ -130,15 +130,19 @@ void MessageHandler::ReportMessage(Isolate* isolate,
}
} else {
for (int i = 0; i < global_length; i++) {
HandleScope scope;
HandleScope scope(isolate);
if (global_listeners.get(i)->IsUndefined()) continue;
Handle<Foreign> callback_obj(Foreign::cast(global_listeners.get(i)));
v8::NeanderObject listener(JSObject::cast(global_listeners.get(i)));
Handle<Foreign> callback_obj(Foreign::cast(listener.get(0)));
v8::MessageCallback callback =
FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address());
Handle<Object> callback_data(listener.get(1), isolate);
{
// Do not allow exceptions to propagate.
v8::TryCatch try_catch;
callback(api_message_obj, api_exception_obj);
callback(api_message_obj, callback_data->IsUndefined()
? api_exception_obj
: v8::Utils::ToLocal(callback_data));
}
if (isolate->has_scheduled_exception()) {
isolate->clear_scheduled_exception();
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/mips/lithium-codegen-mips.cc
Expand Up @@ -3938,7 +3938,7 @@ void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
__ Branch(&not_applicable, ne, scratch, Operand(from_map));

__ li(new_map_reg, Operand(to_map));
if (IsFastSmiElementsKind(from_kind) && IsFastObjectElementsKind(to_kind)) {
if (IsSimpleMapChangeTransition(from_kind, to_kind)) {
__ sw(new_map_reg, FieldMemOperand(object_reg, HeapObject::kMapOffset));
// Write barrier.
__ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg,
Expand Down
9 changes: 7 additions & 2 deletions deps/v8/src/mips/stub-cache-mips.cc
Expand Up @@ -3453,15 +3453,21 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(
// t7: undefined
__ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset));
__ Check(ne, "Function constructed by construct stub.",
a3, Operand(JS_FUNCTION_TYPE));
a3, Operand(JS_FUNCTION_TYPE));
#endif

// Now allocate the JSObject in new space.
// a0: argc
// a1: constructor function
// a2: initial map
// t7: undefined
ASSERT(function->has_initial_map());
__ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset));
#ifdef DEBUG
int instance_size = function->initial_map()->instance_size();
__ Check(eq, "Instance size of initial map changed.",
a3, Operand(instance_size >> kPointerSizeLog2));
#endif
__ AllocateInNewSpace(a3, t4, t5, t6, &generic_stub_call, SIZE_IN_WORDS);

// Allocated the JSObject, now initialize the fields. Map is set to initial
Expand Down Expand Up @@ -3524,7 +3530,6 @@ Handle<Code> ConstructStubCompiler::CompileConstructStub(
}

// Fill the unused in-object property fields with undefined.
ASSERT(function->has_initial_map());
for (int i = shared->this_property_assignments_count();
i < function->initial_map()->inobject_properties();
i++) {
Expand Down

0 comments on commit 81c278d

Please sign in to comment.