diff options
| author | Ben Murdoch <benm@google.com> | 2011-05-05 13:52:32 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:41:47 +0100 |
| commit | b0fe1620dcb4135ac3ab2d66ff93072373911299 (patch) | |
| tree | 3487cdc7e01ec56a6f84ea20f4bae596a0b73986 /src/assembler.cc | |
| parent | df5bff59602802b769e994b0dc1d8869a27fa40c (diff) | |
| download | android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.tar.gz android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.tar.bz2 android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.zip | |
Update V8 to r6101 as required by WebKit r74534
Change-Id: I7f84af8dd732f11898fd644b2c2b1538914cb78d
Diffstat (limited to 'src/assembler.cc')
| -rw-r--r-- | src/assembler.cc | 163 |
1 files changed, 126 insertions, 37 deletions
diff --git a/src/assembler.cc b/src/assembler.cc index 7493673e..eeb84128 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -35,10 +35,12 @@ #include "v8.h" #include "arguments.h" +#include "deoptimizer.h" #include "execution.h" #include "ic-inl.h" #include "factory.h" #include "runtime.h" +#include "runtime-profiler.h" #include "serialize.h" #include "stub-cache.h" #include "regexp-stack.h" @@ -62,6 +64,11 @@ namespace v8 { namespace internal { +const double DoubleConstant::min_int = kMinInt; +const double DoubleConstant::one_half = 0.5; +const double DoubleConstant::negative_infinity = -V8_INFINITY; + + // ----------------------------------------------------------------------------- // Implementation of Label @@ -210,7 +217,7 @@ void RelocInfoWriter::Write(const RelocInfo* rinfo) { #endif Counters::reloc_info_count.Increment(); ASSERT(rinfo->pc() - last_pc_ >= 0); - ASSERT(RelocInfo::NUMBER_OF_MODES < kMaxRelocModes); + ASSERT(RelocInfo::NUMBER_OF_MODES <= kMaxRelocModes); // Use unsigned delta-encoding for pc. uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); RelocInfo::Mode rmode = rinfo->rmode(); @@ -350,12 +357,8 @@ void RelocIterator::next() { Advance(); // Check if we want source positions. if (mode_mask_ & RelocInfo::kPositionMask) { - // Check if we want this type of source position. - if (SetMode(DebugInfoModeFromTag(GetPositionTypeTag()))) { - // Finally read the data before returning. - ReadTaggedData(); - return; - } + ReadTaggedData(); + if (SetMode(DebugInfoModeFromTag(GetPositionTypeTag()))) return; } } else { ASSERT(tag == kDefaultTag); @@ -390,7 +393,7 @@ void RelocIterator::next() { RelocIterator::RelocIterator(Code* code, int mode_mask) { rinfo_.pc_ = code->instruction_start(); rinfo_.data_ = 0; - // relocation info is read backwards + // Relocation info is read backwards. pos_ = code->relocation_start() + code->relocation_size(); end_ = code->relocation_start(); done_ = false; @@ -403,7 +406,7 @@ RelocIterator::RelocIterator(Code* code, int mode_mask) { RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) { rinfo_.pc_ = desc.buffer; rinfo_.data_ = 0; - // relocation info is read backwards + // Relocation info is read backwards. pos_ = desc.buffer + desc.buffer_size; end_ = pos_ - desc.reloc_size; done_ = false; @@ -435,6 +438,8 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) { return "debug break"; case RelocInfo::CODE_TARGET: return "code target"; + case RelocInfo::GLOBAL_PROPERTY_CELL: + return "global property cell"; case RelocInfo::RUNTIME_ENTRY: return "runtime entry"; case RelocInfo::JS_RETURN: @@ -462,27 +467,35 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) { } -void RelocInfo::Print() { - PrintF("%p %s", pc_, RelocModeName(rmode_)); +void RelocInfo::Print(FILE* out) { + PrintF(out, "%p %s", pc_, RelocModeName(rmode_)); if (IsComment(rmode_)) { - PrintF(" (%s)", reinterpret_cast<char*>(data_)); + PrintF(out, " (%s)", reinterpret_cast<char*>(data_)); } else if (rmode_ == EMBEDDED_OBJECT) { - PrintF(" ("); - target_object()->ShortPrint(); - PrintF(")"); + PrintF(out, " ("); + target_object()->ShortPrint(out); + PrintF(out, ")"); } else if (rmode_ == EXTERNAL_REFERENCE) { ExternalReferenceEncoder ref_encoder; - PrintF(" (%s) (%p)", + PrintF(out, " (%s) (%p)", ref_encoder.NameOfAddress(*target_reference_address()), *target_reference_address()); } else if (IsCodeTarget(rmode_)) { Code* code = Code::GetCodeFromTargetAddress(target_address()); - PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address()); + PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()), + target_address()); } else if (IsPosition(rmode_)) { - PrintF(" (%" V8_PTR_PREFIX "d)", data()); + PrintF(out, " (%" V8_PTR_PREFIX "d)", data()); + } else if (rmode_ == RelocInfo::RUNTIME_ENTRY) { + // Depotimization bailouts are stored as runtime entries. + int id = Deoptimizer::GetDeoptimizationId( + target_address(), Deoptimizer::EAGER); + if (id != Deoptimizer::kNotDeoptimizationEntry) { + PrintF(out, " (deoptimization bailout %d)", id); + } } - PrintF("\n"); + PrintF(out, "\n"); } #endif // ENABLE_DISASSEMBLER @@ -493,6 +506,9 @@ void RelocInfo::Verify() { case EMBEDDED_OBJECT: Object::VerifyPointer(target_object()); break; + case GLOBAL_PROPERTY_CELL: + Object::VerifyPointer(target_cell()); + break; case DEBUG_BREAK: #ifndef ENABLE_DEBUGGER_SUPPORT UNREACHABLE(); @@ -599,6 +615,23 @@ ExternalReference ExternalReference::transcendental_cache_array_address() { } +ExternalReference ExternalReference::new_deoptimizer_function() { + return ExternalReference( + Redirect(FUNCTION_ADDR(Deoptimizer::New))); +} + + +ExternalReference ExternalReference::compute_output_frames_function() { + return ExternalReference( + Redirect(FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); +} + + +ExternalReference ExternalReference::global_contexts_list() { + return ExternalReference(Heap::global_contexts_list_address()); +} + + ExternalReference ExternalReference::keyed_lookup_cache_keys() { return ExternalReference(KeyedLookupCache::keys_address()); } @@ -679,6 +712,24 @@ ExternalReference ExternalReference::scheduled_exception_address() { } +ExternalReference ExternalReference::address_of_min_int() { + return ExternalReference(reinterpret_cast<void*>( + const_cast<double*>(&DoubleConstant::min_int))); +} + + +ExternalReference ExternalReference::address_of_one_half() { + return ExternalReference(reinterpret_cast<void*>( + const_cast<double*>(&DoubleConstant::one_half))); +} + + +ExternalReference ExternalReference::address_of_negative_infinity() { + return ExternalReference(reinterpret_cast<void*>( + const_cast<double*>(&DoubleConstant::negative_infinity))); +} + + #ifndef V8_INTERPRETED_REGEXP ExternalReference ExternalReference::re_check_stack_guard_state() { @@ -750,6 +801,51 @@ static double mod_two_doubles(double x, double y) { } +// Helper function to compute x^y, where y is known to be an +// integer. Uses binary decomposition to limit the number of +// multiplications; see the discussion in "Hacker's Delight" by Henry +// S. Warren, Jr., figure 11-6, page 213. +double power_double_int(double x, int y) { + double m = (y < 0) ? 1 / x : x; + unsigned n = (y < 0) ? -y : y; + double p = 1; + while (n != 0) { + if ((n & 1) != 0) p *= m; + m *= m; + if ((n & 2) != 0) p *= m; + m *= m; + n >>= 2; + } + return p; +} + + +double power_double_double(double x, double y) { + int y_int = static_cast<int>(y); + if (y == y_int) { + return power_double_int(x, y_int); // Returns 1.0 for exponent 0. + } + if (!isinf(x)) { + if (y == 0.5) return sqrt(x); + if (y == -0.5) return 1.0 / sqrt(x); + } + if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { + return OS::nan_value(); + } + return pow(x, y); +} + + +ExternalReference ExternalReference::power_double_double_function() { + return ExternalReference(Redirect(FUNCTION_ADDR(power_double_double))); +} + + +ExternalReference ExternalReference::power_double_int_function() { + return ExternalReference(Redirect(FUNCTION_ADDR(power_double_int))); +} + + static int native_compare_doubles(double y, double x) { if (x == y) return EQUAL; return x < y ? LESS : GREATER; @@ -805,19 +901,17 @@ ExternalReference ExternalReference::debug_step_in_fp_address() { #endif -void PositionsRecorder::RecordPosition(int pos, - PositionRecordingType recording_type) { +void PositionsRecorder::RecordPosition(int pos) { ASSERT(pos != RelocInfo::kNoPosition); ASSERT(pos >= 0); - current_position_ = pos; - current_position_recording_type_ = recording_type; + state_.current_position = pos; } void PositionsRecorder::RecordStatementPosition(int pos) { ASSERT(pos != RelocInfo::kNoPosition); ASSERT(pos >= 0); - current_statement_position_ = pos; + state_.current_statement_position = pos; } @@ -826,31 +920,26 @@ bool PositionsRecorder::WriteRecordedPositions() { // Write the statement position if it is different from what was written last // time. - if (current_statement_position_ != written_statement_position_) { + if (state_.current_statement_position != state_.written_statement_position) { EnsureSpace ensure_space(assembler_); assembler_->RecordRelocInfo(RelocInfo::STATEMENT_POSITION, - current_statement_position_); - written_statement_position_ = current_statement_position_; + state_.current_statement_position); + state_.written_statement_position = state_.current_statement_position; written = true; } // Write the position if it is different from what was written last time and - // also different from the written statement position or was forced. - if (current_position_ != written_position_ && - (current_position_ != current_statement_position_ || !written) && - (current_position_ != written_statement_position_ - || current_position_recording_type_ == FORCED_POSITION)) { + // also different from the written statement position. + if (state_.current_position != state_.written_position && + state_.current_position != state_.written_statement_position) { EnsureSpace ensure_space(assembler_); - assembler_->RecordRelocInfo(RelocInfo::POSITION, current_position_); - written_position_ = current_position_; + assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); + state_.written_position = state_.current_position; written = true; } - current_position_recording_type_ = NORMAL_POSITION; - // Return whether something was written. return written; } - } } // namespace v8::internal |
