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 2.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 10, 2010
1 parent 1c5d5e0 commit a5be730
Show file tree
Hide file tree
Showing 54 changed files with 875 additions and 276 deletions.
1 change: 1 addition & 0 deletions deps/v8/AUTHORS
Expand Up @@ -28,4 +28,5 @@ Rene Rebe <rene@exactcode.de>
Rodolph Perfetta <rodolph.perfetta@arm.com>
Ryan Dahl <coldredlemur@gmail.com>
Subrato K De <subratokde@codeaurora.org>
Burcu Dogan <burcujdogan@gmail.com>

10 changes: 10 additions & 0 deletions deps/v8/ChangeLog
@@ -1,3 +1,13 @@
2010-08-09: Version 2.3.6

RegExp literals create a new object every time they are evaluated
(issue 704).

Object.seal and Object.freeze return the modified object (issue 809).

Fix building using GCC 4.4.4.


2010-08-04: Version 2.3.5

Added support for ES5 property names. Object initialisers and
Expand Down
1 change: 1 addition & 0 deletions deps/v8/SConstruct
Expand Up @@ -300,6 +300,7 @@ V8_EXTRA_FLAGS = {
'gcc': {
'all': {
'WARNINGFLAGS': ['-Wall',
'-Werror',
'-W',
'-Wno-unused-parameter',
'-Wnon-virtual-dtor']
Expand Down
12 changes: 10 additions & 2 deletions deps/v8/src/api.cc
Expand Up @@ -126,7 +126,7 @@ static FatalErrorCallback& GetFatalErrorHandler() {

// When V8 cannot allocated memory FatalProcessOutOfMemory is called.
// The default fatal error handler is called and execution is stopped.
void i::V8::FatalProcessOutOfMemory(const char* location) {
void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
i::HeapStats heap_stats;
int start_marker;
heap_stats.start_marker = &start_marker;
Expand Down Expand Up @@ -166,9 +166,17 @@ void i::V8::FatalProcessOutOfMemory(const char* location) {
heap_stats.near_death_global_handle_count = &near_death_global_handle_count;
int destroyed_global_handle_count;
heap_stats.destroyed_global_handle_count = &destroyed_global_handle_count;
int memory_allocator_size;
heap_stats.memory_allocator_size = &memory_allocator_size;
int memory_allocator_capacity;
heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
int objects_per_type[LAST_TYPE + 1] = {0};
heap_stats.objects_per_type = objects_per_type;
int size_per_type[LAST_TYPE + 1] = {0};
heap_stats.size_per_type = size_per_type;
int end_marker;
heap_stats.end_marker = &end_marker;
i::Heap::RecordStats(&heap_stats);
i::Heap::RecordStats(&heap_stats, take_snapshot);
i::V8::SetFatalError();
FatalErrorCallback callback = GetFatalErrorHandler();
{
Expand Down
18 changes: 8 additions & 10 deletions deps/v8/src/arm/assembler-arm-inl.h
Expand Up @@ -120,9 +120,8 @@ Address RelocInfo::call_address() {


void RelocInfo::set_call_address(Address target) {
ASSERT(IsPatchedReturnSequence());
// The 2 instructions offset assumes patched return sequence.
ASSERT(IsJSReturn(rmode()));
ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
Memory::Address_at(pc_ + 2 * Assembler::kInstrSize) = target;
}

Expand All @@ -132,16 +131,15 @@ Object* RelocInfo::call_object() {
}


Object** RelocInfo::call_object_address() {
ASSERT(IsPatchedReturnSequence());
// The 2 instructions offset assumes patched return sequence.
ASSERT(IsJSReturn(rmode()));
return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize);
void RelocInfo::set_call_object(Object* target) {
*call_object_address() = target;
}


void RelocInfo::set_call_object(Object* target) {
*call_object_address() = target;
Object** RelocInfo::call_object_address() {
ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize);
}


Expand Down
72 changes: 58 additions & 14 deletions deps/v8/src/arm/codegen-arm.cc
Expand Up @@ -3280,13 +3280,13 @@ void CodeGenerator::VisitRegExpLiteral(RegExpLiteral* node) {
FixedArray::kHeaderSize + node->literal_index() * kPointerSize;
__ ldr(literal, FieldMemOperand(tmp, literal_offset));

JumpTarget done;
JumpTarget materialized;
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
__ cmp(literal, ip);
// This branch locks the virtual frame at the done label to match the
// one we have here, where the literal register is not on the stack and
// nothing is spilled.
done.Branch(ne);
materialized.Branch(ne);

// If the entry is undefined we call the runtime system to compute
// the literal.
Expand All @@ -3301,11 +3301,23 @@ void CodeGenerator::VisitRegExpLiteral(RegExpLiteral* node) {
frame_->CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
__ Move(literal, r0);

// This call to bind will get us back to the virtual frame we had before
// where things are not spilled and the literal register is not on the stack.
done.Bind();
// Push the literal.
materialized.Bind();

frame_->EmitPush(literal);
int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
frame_->EmitPush(Operand(Smi::FromInt(size)));
frame_->CallRuntime(Runtime::kAllocateInNewSpace, 1);
// TODO(lrn): Use AllocateInNewSpace macro with fallback to runtime.
// r0 is newly allocated space.

// Reuse literal variable with (possibly) a new register, still holding
// the materialized boilerplate.
literal = frame_->PopToRegister(r0);

__ CopyFields(r0, literal, tmp.bit(), size / kPointerSize);

// Push the clone.
frame_->EmitPush(r0);
ASSERT_EQ(original_height + 1, frame_->height());
}

Expand Down Expand Up @@ -5324,6 +5336,44 @@ void CodeGenerator::GenerateObjectEquals(ZoneList<Expression*>* args) {
}


void CodeGenerator::GenerateIsRegExpEquivalent(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);

// Load the two objects into registers and perform the comparison.
Load(args->at(0));
Load(args->at(1));
Register right = frame_->PopToRegister();
Register left = frame_->PopToRegister(right);
Register tmp = frame_->scratch0();
Register tmp2 = frame_->scratch1();

// Jumps to done must have the eq flag set if the test is successful
// and clear if the test has failed.
Label done;

// Fail if either is a non-HeapObject.
__ cmp(left, Operand(right));
__ b(eq, &done);
__ and_(tmp, left, Operand(right));
__ eor(tmp, tmp, Operand(kSmiTagMask));
__ tst(tmp, Operand(kSmiTagMask));
__ b(ne, &done);
__ ldr(tmp, FieldMemOperand(left, HeapObject::kMapOffset));
__ ldrb(tmp2, FieldMemOperand(tmp, Map::kInstanceTypeOffset));
__ cmp(tmp2, Operand(JS_REGEXP_TYPE));
__ b(ne, &done);
__ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset));
__ cmp(tmp, Operand(tmp2));
__ b(ne, &done);
__ ldr(tmp, FieldMemOperand(left, JSRegExp::kDataOffset));
__ ldr(tmp2, FieldMemOperand(right, JSRegExp::kDataOffset));
__ cmp(tmp, tmp2);
__ bind(&done);
cc_reg_ = eq;
}



void CodeGenerator::VisitCallRuntime(CallRuntime* node) {
#ifdef DEBUG
int original_height = frame_->height();
Expand Down Expand Up @@ -6908,10 +6958,7 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
__ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset));

// Copy the elements array.
for (int i = 0; i < elements_size; i += kPointerSize) {
__ ldr(r1, FieldMemOperand(r3, i));
__ str(r1, FieldMemOperand(r2, i));
}
__ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize);
}

// Return and remove the on-stack parameters.
Expand Down Expand Up @@ -9780,10 +9827,7 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
__ ldr(r4, MemOperand(r4, offset));

// Copy the JS object part.
for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) {
__ ldr(r3, FieldMemOperand(r4, i));
__ str(r3, FieldMemOperand(r0, i));
}
__ CopyFields(r0, r4, r3.bit(), JSObject::kHeaderSize / kPointerSize);

// Setup the callee in-object property.
STATIC_ASSERT(Heap::arguments_callee_index == 0);
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/arm/codegen-arm.h
Expand Up @@ -544,6 +544,8 @@ class CodeGenerator: public AstVisitor {
void GenerateMathCos(ZoneList<Expression*>* args);
void GenerateMathSqrt(ZoneList<Expression*>* args);

void GenerateIsRegExpEquivalent(ZoneList<Expression*>* args);

// Simple condition analysis.
enum ConditionAnalysis {
ALWAYS_TRUE,
Expand Down
60 changes: 56 additions & 4 deletions deps/v8/src/arm/full-codegen-arm.cc
Expand Up @@ -1104,27 +1104,38 @@ void FullCodeGenerator::EmitVariableLoad(Variable* var,

void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
Comment cmnt(masm_, "[ RegExpLiteral");
Label done;
Label materialized;
// Registers will be used as follows:
// r4 = JS function, literals array
// r3 = literal index
// r2 = RegExp pattern
// r1 = RegExp flags
// r0 = temp + return value (RegExp literal)
// r0 = temp + materialized value (RegExp literal)
__ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset));
int literal_offset =
FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
__ ldr(r0, FieldMemOperand(r4, literal_offset));
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
__ cmp(r0, ip);
__ b(ne, &done);
__ b(ne, &materialized);
__ mov(r3, Operand(Smi::FromInt(expr->literal_index())));
__ mov(r2, Operand(expr->pattern()));
__ mov(r1, Operand(expr->flags()));
__ Push(r4, r3, r2, r1);
__ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
__ bind(&done);
__ bind(&materialized);
int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
__ push(r0);
__ mov(r0, Operand(Smi::FromInt(size)));
__ push(r0);
__ CallRuntime(Runtime::kAllocateInNewSpace, 1);
// After this, registers are used as follows:
// r0: Newly allocated regexp.
// r1: Materialized regexp
// r2: temp.
__ pop(r1);
__ CopyFields(r0, r1, r2.bit(), size / kPointerSize);
Apply(context_, r0);
}

Expand Down Expand Up @@ -2566,6 +2577,47 @@ void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) {
}


void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) {
ASSERT_EQ(2, args->length());

Register right = r0;
Register left = r1;
Register tmp = r2;
Register tmp2 = r3;

VisitForValue(args->at(0), kStack);
VisitForValue(args->at(1), kAccumulator);
__ pop(left);

Label done, fail, ok;
__ cmp(left, Operand(right));
__ b(eq, &ok);
// Fail if either is a non-HeapObject.
__ and_(tmp, left, Operand(right));
__ tst(tmp, Operand(kSmiTagMask));
__ b(eq, &fail);
__ ldr(tmp, FieldMemOperand(left, HeapObject::kMapOffset));
__ ldrb(tmp2, FieldMemOperand(tmp, Map::kInstanceTypeOffset));
__ cmp(tmp2, Operand(JS_REGEXP_TYPE));
__ b(ne, &fail);
__ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset));
__ cmp(tmp, Operand(tmp2));
__ b(ne, &fail);
__ ldr(tmp, FieldMemOperand(left, JSRegExp::kDataOffset));
__ ldr(tmp2, FieldMemOperand(right, JSRegExp::kDataOffset));
__ cmp(tmp, tmp2);
__ b(eq, &ok);
__ bind(&fail);
__ LoadRoot(r0, Heap::kFalseValueRootIndex);
__ jmp(&done);
__ bind(&ok);
__ LoadRoot(r0, Heap::kTrueValueRootIndex);
__ bind(&done);

Apply(context_, r0);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
Handle<String> name = expr->name();
if (name->length() > 0 && name->Get(0) == '_') {
Expand Down
17 changes: 12 additions & 5 deletions deps/v8/src/arm/ic-arm.cc
Expand Up @@ -1105,7 +1105,7 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
// -- r0 : key
// -- r1 : receiver
// -----------------------------------
Label slow, check_string, index_smi, index_string;
Label slow, check_string, index_smi, index_string, property_array_property;
Label check_pixel_array, probe_dictionary, check_number_dictionary;

Register key = r0;
Expand Down Expand Up @@ -1193,7 +1193,7 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
__ cmp(r0, r5);
__ b(ne, &slow);

// Get field offset and check that it is an in-object property.
// Get field offset.
// r0 : key
// r1 : receiver
// r2 : receiver's map
Expand All @@ -1203,18 +1203,25 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
__ mov(r4, Operand(cache_field_offsets));
__ ldr(r5, MemOperand(r4, r3, LSL, kPointerSizeLog2));
__ ldrb(r6, FieldMemOperand(r2, Map::kInObjectPropertiesOffset));
__ cmp(r5, r6);
__ b(ge, &slow);
__ sub(r5, r5, r6, SetCC);
__ b(ge, &property_array_property);

// Load in-object property.
__ sub(r5, r5, r6); // Index from end of object.
__ ldrb(r6, FieldMemOperand(r2, Map::kInstanceSizeOffset));
__ add(r6, r6, r5); // Index from start of object.
__ sub(r1, r1, Operand(kHeapObjectTag)); // Remove the heap tag.
__ ldr(r0, MemOperand(r1, r6, LSL, kPointerSizeLog2));
__ IncrementCounter(&Counters::keyed_load_generic_lookup_cache, 1, r2, r3);
__ Ret();

// Load property array property.
__ bind(&property_array_property);
__ ldr(r1, FieldMemOperand(r1, JSObject::kPropertiesOffset));
__ add(r1, r1, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ ldr(r0, MemOperand(r1, r5, LSL, kPointerSizeLog2));
__ IncrementCounter(&Counters::keyed_load_generic_lookup_cache, 1, r2, r3);
__ Ret();

// Do a quick inline probe of the receiver's dictionary, if it
// exists.
__ bind(&probe_dictionary);
Expand Down
28 changes: 28 additions & 0 deletions deps/v8/src/arm/macro-assembler-arm.cc
Expand Up @@ -1728,6 +1728,34 @@ void MacroAssembler::AllocateHeapNumberWithValue(Register result,
}


// Copies a fixed number of fields of heap objects from src to dst.
void MacroAssembler::CopyFields(Register dst,
Register src,
RegList temps,
int field_count) {
// At least one bit set in the first 15 registers.
ASSERT((temps & ((1 << 15) - 1)) != 0);
ASSERT((temps & dst.bit()) == 0);
ASSERT((temps & src.bit()) == 0);
// Primitive implementation using only one temporary register.

Register tmp = no_reg;
// Find a temp register in temps list.
for (int i = 0; i < 15; i++) {
if ((temps & (1 << i)) != 0) {
tmp.set_code(i);
break;
}
}
ASSERT(!tmp.is(no_reg));

for (int i = 0; i < field_count; i++) {
ldr(tmp, FieldMemOperand(src, i * kPointerSize));
str(tmp, FieldMemOperand(dst, i * kPointerSize));
}
}


void MacroAssembler::CountLeadingZeros(Register zeros, // Answer.
Register source, // Input.
Register scratch) {
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/arm/macro-assembler-arm.h
Expand Up @@ -393,6 +393,8 @@ class MacroAssembler: public Assembler {
Register heap_number_map,
Label* gc_required);

// Copies a fixed number of fields of heap objects from src to dst.
void CopyFields(Register dst, Register src, RegList temps, int field_count);

// ---------------------------------------------------------------------------
// Support functions.
Expand Down

5 comments on commit a5be730

@akaspin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make install fails on Debian Squeeze x64:

cc1plus: warnings being treated as errors
/tmp/node/deps/v8/src/handles-inl.h: In static member function 'static void v8::V8::RemoveMessageListeners(void (*)(v8::Handle<v8::Message>, v8::Handle<v8::Value>))':
/tmp/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/tmp/node/deps/v8/src/api.h:58: note: initialized from here
/tmp/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/tmp/node/deps/v8/src/api.h:58: note: initialized from here
/tmp/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/tmp/node/deps/v8/src/api.h:58: note: initialized from here
/tmp/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
/tmp/node/deps/v8/src/handles-inl.h:50: note: initialized from here
/tmp/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/tmp/node/deps/v8/src/api.h:58: note: initialized from here
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
/tmp/node/deps/v8/src/handles.h:81: note: initialized from here
scons: *** [obj/release/api.o] Error 1
scons: building terminated because of errors.
Waf: Leaving directory `/tmp/node/build'
Build failed:  -> task failed (err #2):
        {task: libv8.a SConstruct -> libv8.a}
make: *** [install] Error 1

UPD: Sorry make produces same errors:

g++ -o obj/release/bootstrapper.o -c -Wall -Werror -W -Wno-unused-parameter -Wnon-virtual-dtor -pedantic -m64 -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -fno-rtti -fno-exceptions -Wall -Werror -W -Wno-unused-parameter -Wnon-virtual-dtor -pedantic -m64 -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -DV8_TARGET_ARCH_X64 -DENABLE_VMSTATE_TRACKING -DENABLE_LOGGING_AND_PROFILING -DENABLE_DEBUGGER_SUPPORT -I/home/locadmin/src/node/deps/v8/src /home/locadmin/src/node/deps/v8/src/bootstrapper.cc
cc1plus: warnings being treated as errors
/home/locadmin/src/node/deps/v8/src/handles-inl.h: In static member function 'static void v8::V8::RemoveMessageListeners(void (*)(v8::Handle<v8::Message>, v8::Handle<v8::Value>))':
/home/locadmin/src/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/home/locadmin/src/node/deps/v8/src/api.h:58: note: initialized from here
/home/locadmin/src/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/home/locadmin/src/node/deps/v8/src/api.h:58: note: initialized from here
/home/locadmin/src/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/home/locadmin/src/node/deps/v8/src/api.h:58: note: initialized from here
/home/locadmin/src/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
/home/locadmin/src/node/deps/v8/src/handles-inl.h:50: note: initialized from here
/home/locadmin/src/node/deps/v8/src/handles-inl.h:50: error: dereferencing pointer 'SR.2730' does break strict-aliasing rules
/home/locadmin/src/node/deps/v8/src/api.h:58: note: initialized from here
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
cc1plus: error: dereferencing pointer '<anonymous>' does break strict-aliasing rules
/home/locadmin/src/node/deps/v8/src/handles.h:81: note: initialized from here
scons: *** [obj/release/api.o] Error 1
scons: building terminated because of errors.
Waf: Leaving directory `/home/locadmin/src/node/build'
Build failed:  -> task failed (err #2):
        {task: libv8.a SConstruct -> libv8.a}
make: *** [all] Error 1

@mhussa
Copy link

@mhussa mhussa commented on a5be730 Aug 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a thread discussing the issue: http://code.google.com/p/v8/issues/detail?id=413

I performed an export GCC_VERSION=44 and it worked on my ubuntu 10.04. build.

@mhussa
Copy link

@mhussa mhussa commented on a5be730 Aug 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a thread discussing the issue:

http://code.google.com/p/v8/issues/detail?id=413

I used GCC_VERSION=44 to build on ubuntu 10.04 64bit.

@akaspin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks mhussa. export GCC_VERSION=44 solves problem. But it's still a bug.

@mscdex
Copy link

@mscdex mscdex commented on a5be730 Aug 11, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new commit in node just fixed this problem.

Please sign in to comment.