Skip to content

Commit

Permalink
Upgrade V8 to 2.2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 15, 2010
1 parent f3cd7bb commit bc76624
Show file tree
Hide file tree
Showing 36 changed files with 2,142 additions and 237 deletions.
11 changes: 9 additions & 2 deletions deps/v8/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
2010-06-07: Version 2.2.16
2010-06-14: Version 2.2.17

Remove the SetExternalStringDiposeCallback API. Changed the
Improved debugger support for stepping out of functions.

Incremental performance improvements.


2010-06-09: Version 2.2.16

Removed the SetExternalStringDiposeCallback API. Changed the
disposal of external string resources to call a virtual Dispose
method on the resource.

Expand Down
5 changes: 5 additions & 0 deletions deps/v8/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def GetOptions():
result = Options()
result.Add('mode', 'compilation mode (debug, release)', 'release')
result.Add('sample', 'build sample (shell, process, lineprocessor)', '')
result.Add('cache', 'directory to use for scons build cache', '')
result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,...)', '')
result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '')
for (name, option) in SIMPLE_OPTIONS.iteritems():
Expand Down Expand Up @@ -862,6 +863,8 @@ def VerifyOptions(env):
Abort("Shared Object soname not applicable for static library.")
if env['os'] != 'win32' and env['pgo'] != 'off':
Abort("Profile guided optimization only supported on Windows.")
if env['cache'] and not os.path.isdir(env['cache']):
Abort("The specified cache directory does not exist.")
if not (env['arch'] == 'arm' or env['simulator'] == 'arm') and ('unalignedaccesses' in ARGUMENTS):
print env['arch']
print env['simulator']
Expand Down Expand Up @@ -1130,6 +1133,8 @@ def Build():
else:
env.Default('library')

if env['cache']:
CacheDir(env['cache'])

# We disable deprecation warnings because we need to be able to use
# env.Copy without getting warnings for compatibility with older
Expand Down
131 changes: 124 additions & 7 deletions deps/v8/src/arm/codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5087,18 +5087,28 @@ void CodeGenerator::GenerateCallFunction(ZoneList<Expression*>* args) {

void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) {
ASSERT_EQ(args->length(), 1);
// Load the argument on the stack and jump to the runtime.
Load(args->at(0));
frame_->CallRuntime(Runtime::kMath_sin, 1);
if (CpuFeatures::IsSupported(VFP3)) {
TranscendentalCacheStub stub(TranscendentalCache::SIN);
frame_->SpillAllButCopyTOSToR0();
frame_->CallStub(&stub, 1);
} else {
frame_->CallRuntime(Runtime::kMath_sin, 1);
}
frame_->EmitPush(r0);
}


void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) {
ASSERT_EQ(args->length(), 1);
// Load the argument on the stack and jump to the runtime.
Load(args->at(0));
frame_->CallRuntime(Runtime::kMath_cos, 1);
if (CpuFeatures::IsSupported(VFP3)) {
TranscendentalCacheStub stub(TranscendentalCache::COS);
frame_->SpillAllButCopyTOSToR0();
frame_->CallStub(&stub, 1);
} else {
frame_->CallRuntime(Runtime::kMath_cos, 1);
}
frame_->EmitPush(r0);
}

Expand Down Expand Up @@ -7090,7 +7100,7 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
CpuFeatures::Scope scope(VFP3);
__ CheckMap(object,
scratch1,
Factory::heap_number_map(),
Heap::kHeapNumberMapRootIndex,
not_found,
true);

Expand Down Expand Up @@ -8236,6 +8246,110 @@ Handle<Code> GetBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info) {
}


void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
// Argument is a number and is on stack and in r0.
Label runtime_call;
Label input_not_smi;
Label loaded;

if (CpuFeatures::IsSupported(VFP3)) {
// Load argument and check if it is a smi.
__ BranchOnNotSmi(r0, &input_not_smi);

CpuFeatures::Scope scope(VFP3);
// Input is a smi. Convert to double and load the low and high words
// of the double into r2, r3.
__ IntegerToDoubleConversionWithVFP3(r0, r3, r2);
__ b(&loaded);

__ bind(&input_not_smi);
// Check if input is a HeapNumber.
__ CheckMap(r0,
r1,
Heap::kHeapNumberMapRootIndex,
&runtime_call,
true);
// Input is a HeapNumber. Load it to a double register and store the
// low and high words into r2, r3.
__ Ldrd(r2, r3, FieldMemOperand(r0, HeapNumber::kValueOffset));

__ bind(&loaded);
// r2 = low 32 bits of double value
// r3 = high 32 bits of double value
// Compute hash:
// h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
__ eor(r1, r2, Operand(r3));
__ eor(r1, r1, Operand(r1, LSR, 16));
__ eor(r1, r1, Operand(r1, LSR, 8));
ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
if (CpuFeatures::IsSupported(ARMv7)) {
const int kTranscendentalCacheSizeBits = 9;
ASSERT_EQ(1 << kTranscendentalCacheSizeBits,
TranscendentalCache::kCacheSize);
__ ubfx(r1, r1, 0, kTranscendentalCacheSizeBits);
} else {
__ and_(r1, r1, Operand(TranscendentalCache::kCacheSize - 1));
}

// r2 = low 32 bits of double value.
// r3 = high 32 bits of double value.
// r1 = TranscendentalCache::hash(double value).
__ mov(r0,
Operand(ExternalReference::transcendental_cache_array_address()));
// r0 points to cache array.
__ ldr(r0, MemOperand(r0, type_ * sizeof(TranscendentalCache::caches_[0])));
// r0 points to the cache for the type type_.
// If NULL, the cache hasn't been initialized yet, so go through runtime.
__ cmp(r0, Operand(0));
__ b(eq, &runtime_call);

#ifdef DEBUG
// Check that the layout of cache elements match expectations.
{ TranscendentalCache::Element test_elem[2];
char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer.
CHECK_EQ(0, elem_in0 - elem_start);
CHECK_EQ(kIntSize, elem_in1 - elem_start);
CHECK_EQ(2 * kIntSize, elem_out - elem_start);
}
#endif

// Find the address of the r1'st entry in the cache, i.e., &r0[r1*12].
__ add(r1, r1, Operand(r1, LSL, 1));
__ add(r0, r0, Operand(r1, LSL, 2));
// Check if cache matches: Double value is stored in uint32_t[2] array.
__ ldm(ia, r0, r4.bit()| r5.bit() | r6.bit());
__ cmp(r2, r4);
__ b(ne, &runtime_call);
__ cmp(r3, r5);
__ b(ne, &runtime_call);
// Cache hit. Load result, pop argument and return.
__ mov(r0, Operand(r6));
__ pop();
__ Ret();
}

__ bind(&runtime_call);
__ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1);
}


Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
switch (type_) {
// Add more cases when necessary.
case TranscendentalCache::SIN: return Runtime::kMath_sin;
case TranscendentalCache::COS: return Runtime::kMath_cos;
default:
UNIMPLEMENTED();
return Runtime::kAbort;
}
}


void StackCheckStub::Generate(MacroAssembler* masm) {
// Do tail-call to runtime routine. Runtime routines expect at least one
// argument, so give it a Smi.
Expand Down Expand Up @@ -9550,8 +9664,11 @@ void StringCharCodeAtGenerator::GenerateSlow(
// Index is not a smi.
__ bind(&index_not_smi_);
// If index is a heap number, try converting it to an integer.
__ CheckMap(index_, scratch_,
Factory::heap_number_map(), index_not_number_, true);
__ CheckMap(index_,
scratch_,
Heap::kHeapNumberMapRootIndex,
index_not_number_,
true);
call_helper.BeforeCall(masm);
__ Push(object_, index_);
__ push(index_); // Consumed by runtime conversion function.
Expand Down
15 changes: 15 additions & 0 deletions deps/v8/src/arm/codegen-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,21 @@ class CodeGenerator: public AstVisitor {
};


// Compute a transcendental math function natively, or call the
// TranscendentalCache runtime function.
class TranscendentalCacheStub: public CodeStub {
public:
explicit TranscendentalCacheStub(TranscendentalCache::Type type)
: type_(type) {}
void Generate(MacroAssembler* masm);
private:
TranscendentalCache::Type type_;
Major MajorKey() { return TranscendentalCache; }
int MinorKey() { return type_; }
Runtime::FunctionId RuntimeFunction();
};


class GenericBinaryOpStub : public CodeStub {
public:
GenericBinaryOpStub(Token::Value op,
Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/arm/full-codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ void FullCodeGenerator::Generate(CompilationInfo* info, Mode mode) {
// body.
__ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
}
EmitReturnSequence(function()->end_position());
EmitReturnSequence();
}


void FullCodeGenerator::EmitReturnSequence(int position) {
void FullCodeGenerator::EmitReturnSequence() {
Comment cmnt(masm_, "[ Return sequence");
if (return_label_.is_bound()) {
__ b(&return_label_);
Expand All @@ -224,7 +224,7 @@ void FullCodeGenerator::EmitReturnSequence(int position) {
// Here we use masm_-> instead of the __ macro to avoid the code coverage
// tool from instrumenting as we rely on the code size here.
int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize;
CodeGenerator::RecordPositions(masm_, position);
CodeGenerator::RecordPositions(masm_, function()->end_position());
__ RecordJSReturn();
masm_->mov(sp, fp);
masm_->ldm(ia_w, sp, fp.bit() | lr.bit());
Expand Down
15 changes: 15 additions & 0 deletions deps/v8/src/arm/macro-assembler-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,21 @@ void MacroAssembler::CheckMap(Register obj,
}


void MacroAssembler::CheckMap(Register obj,
Register scratch,
Heap::RootListIndex index,
Label* fail,
bool is_heap_object) {
if (!is_heap_object) {
BranchOnSmi(obj, fail);
}
ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset));
LoadRoot(ip, index);
cmp(scratch, ip);
b(ne, fail);
}


void MacroAssembler::TryGetFunctionPrototype(Register function,
Register result,
Register scratch,
Expand Down
14 changes: 11 additions & 3 deletions deps/v8/src/arm/macro-assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,23 @@ class MacroAssembler: public Assembler {
InstanceType type);


// Check if the map of an object is equal to a specified map and
// branch to label if not. Skip the smi check if not required
// (object is known to be a heap object)
// Check if the map of an object is equal to a specified map (either
// given directly or as an index into the root list) and branch to
// label if not. Skip the smi check if not required (object is known
// to be a heap object)
void CheckMap(Register obj,
Register scratch,
Handle<Map> map,
Label* fail,
bool is_heap_object);

void CheckMap(Register obj,
Register scratch,
Heap::RootListIndex index,
Label* fail,
bool is_heap_object);


// Load and check the instance type of an object for being a string.
// Loads the type into the second argument register.
// Returns a condition that will be enabled if the object was a string.
Expand Down
34 changes: 34 additions & 0 deletions deps/v8/src/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,40 @@ void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
}


bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
HandleScope scope;

// Get the executing function in which the debug break occurred.
Handle<SharedFunctionInfo> shared =
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
if (!EnsureDebugInfo(shared)) {
// Return if we failed to retrieve the debug info.
return false;
}
Handle<DebugInfo> debug_info = GetDebugInfo(shared);
Handle<Code> code(debug_info->code());
#ifdef DEBUG
// Get the code which is actually executing.
Handle<Code> frame_code(frame->code());
ASSERT(frame_code.is_identical_to(code));
#endif

// Find the call address in the running code.
Address addr = frame->pc() - Assembler::kCallTargetAddressOffset;

// Check if the location is at JS return.
RelocIterator it(debug_info->code());
while (!it.done()) {
if (RelocInfo::IsJSReturn(it.rinfo()->rmode())) {
return (it.rinfo()->pc() ==
addr - Assembler::kPatchReturnSequenceAddressOffset);
}
it.next();
}
return false;
}


void Debug::FramesHaveBeenDropped(StackFrame::Id new_break_frame_id) {
thread_local_.frames_are_dropped_ = true;
thread_local_.break_frame_id_ = new_break_frame_id;
Expand Down
3 changes: 3 additions & 0 deletions deps/v8/src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ class Debug {
// Check whether a global object is the debug global object.
static bool IsDebugGlobal(GlobalObject* global);

// Check whether this frame is just about to return.
static bool IsBreakAtReturn(JavaScriptFrame* frame);

// Fast check to see if any break points are active.
inline static bool has_break_points() { return has_break_points_; }

Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ DEFINE_bool(trace_gc_verbose, false,
"print more details following each garbage collection")
DEFINE_bool(collect_maps, true,
"garbage collect maps from which no objects can be reached")
DEFINE_bool(flush_code, false,
"flush code that we expect not to use again before full gc")

// v8.cc
DEFINE_bool(use_idle_notification, true,
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ void FullCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
}
__ Drop(stack_depth);

EmitReturnSequence(stmt->statement_pos());
EmitReturnSequence();
}


Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/full-codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class FullCodeGenerator: public AstVisitor {
FunctionLiteral* function);

// Platform-specific return sequence
void EmitReturnSequence(int position);
void EmitReturnSequence();

// Platform-specific code sequences for calls
void EmitCallWithStub(Call* expr);
Expand Down
9 changes: 3 additions & 6 deletions deps/v8/src/heap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,9 @@ void Heap::RecordWrite(Address address, int offset) {
void Heap::RecordWrites(Address address, int start, int len) {
if (new_space_.Contains(address)) return;
ASSERT(!new_space_.FromSpaceContains(address));
for (int offset = start;
offset < start + len * kPointerSize;
offset += kPointerSize) {
SLOW_ASSERT(Contains(address + offset));
Page::FromAddress(address)->MarkRegionDirty(address + offset);
}
Page* page = Page::FromAddress(address);
page->SetRegionMarks(page->GetRegionMarks() |
page->GetRegionMaskForSpan(address + start, len * kPointerSize));
}


Expand Down
Loading

0 comments on commit bc76624

Please sign in to comment.