vendor/v8/src/assembler.cc in mustang-0.0.1 vs vendor/v8/src/assembler.cc in mustang-0.1.0

- old
+ new

@@ -53,10 +53,12 @@ #include "ia32/regexp-macro-assembler-ia32.h" #elif V8_TARGET_ARCH_X64 #include "x64/regexp-macro-assembler-x64.h" #elif V8_TARGET_ARCH_ARM #include "arm/regexp-macro-assembler-arm.h" +#elif V8_TARGET_ARCH_MIPS +#include "mips/regexp-macro-assembler-mips.h" #else // Unknown architecture. #error "Unknown architecture." #endif // Target architecture. #endif // V8_INTERPRETED_REGEXP @@ -65,10 +67,11 @@ const double DoubleConstant::min_int = kMinInt; const double DoubleConstant::one_half = 0.5; const double DoubleConstant::minus_zero = -0.0; +const double DoubleConstant::nan = OS::nan_value(); const double DoubleConstant::negative_infinity = -V8_INFINITY; const char* RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; // ----------------------------------------------------------------------------- // Implementation of Label @@ -137,10 +140,11 @@ const int kPCJumpTag = (1 << kExtraTagBits) - 1; const int kSmallPCDeltaBits = kBitsPerByte - kTagBits; const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1; +const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask; const int kVariableLengthPCJumpTopTag = 1; const int kChunkBits = 7; const int kChunkMask = (1 << kChunkBits) - 1; const int kLastChunkTagBits = 1; @@ -214,11 +218,10 @@ void RelocInfoWriter::Write(const RelocInfo* rinfo) { #ifdef DEBUG byte* begin_pos = pos_; #endif - Counters::reloc_info_count.Increment(); ASSERT(rinfo->pc() - last_pc_ >= 0); 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(); @@ -250,11 +253,11 @@ } else if (RelocInfo::IsComment(rmode)) { // Comments are normally not generated, so we use the costly encoding. WriteExtraTaggedPC(pc_delta, kPCJumpTag); WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag); last_data_ = rinfo->data(); - ASSERT(begin_pos - pos_ == RelocInfo::kRelocCommentSize); + ASSERT(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); } else { // For all other modes we simply use the mode as the extra tag. // None of these modes need a data component. ASSERT(rmode < kPCJumpTag && rmode < kDataJumpTag); WriteExtraTaggedPC(pc_delta, rmode); @@ -523,11 +526,11 @@ // convert inline target address to code object Address addr = target_address(); ASSERT(addr != NULL); // Check that we can find the right code object. Code* code = Code::GetCodeFromTargetAddress(addr); - Object* found = Heap::FindCodeObject(addr); + Object* found = HEAP->FindCodeObject(addr); ASSERT(found->IsCode()); ASSERT(code->address() == HeapObject::cast(found)->address()); break; } case RUNTIME_ENTRY: @@ -549,157 +552,188 @@ // ----------------------------------------------------------------------------- // Implementation of ExternalReference -ExternalReference::ExternalReference(Builtins::CFunctionId id) - : address_(Redirect(Builtins::c_function_address(id))) {} +ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate) + : address_(Redirect(isolate, Builtins::c_function_address(id))) {} ExternalReference::ExternalReference( - ApiFunction* fun, Type type = ExternalReference::BUILTIN_CALL) - : address_(Redirect(fun->address(), type)) {} + ApiFunction* fun, + Type type = ExternalReference::BUILTIN_CALL, + Isolate* isolate = NULL) + : address_(Redirect(isolate, fun->address(), type)) {} -ExternalReference::ExternalReference(Builtins::Name name) - : address_(Builtins::builtin_address(name)) {} +ExternalReference::ExternalReference(Builtins::Name name, Isolate* isolate) + : address_(isolate->builtins()->builtin_address(name)) {} -ExternalReference::ExternalReference(Runtime::FunctionId id) - : address_(Redirect(Runtime::FunctionForId(id)->entry)) {} +ExternalReference::ExternalReference(Runtime::FunctionId id, + Isolate* isolate) + : address_(Redirect(isolate, Runtime::FunctionForId(id)->entry)) {} -ExternalReference::ExternalReference(Runtime::Function* f) - : address_(Redirect(f->entry)) {} +ExternalReference::ExternalReference(const Runtime::Function* f, + Isolate* isolate) + : address_(Redirect(isolate, f->entry)) {} -ExternalReference::ExternalReference(const IC_Utility& ic_utility) - : address_(Redirect(ic_utility.address())) {} +ExternalReference ExternalReference::isolate_address() { + return ExternalReference(Isolate::Current()); +} + +ExternalReference::ExternalReference(const IC_Utility& ic_utility, + Isolate* isolate) + : address_(Redirect(isolate, ic_utility.address())) {} + #ifdef ENABLE_DEBUGGER_SUPPORT -ExternalReference::ExternalReference(const Debug_Address& debug_address) - : address_(debug_address.address()) {} +ExternalReference::ExternalReference(const Debug_Address& debug_address, + Isolate* isolate) + : address_(debug_address.address(isolate)) {} #endif ExternalReference::ExternalReference(StatsCounter* counter) : address_(reinterpret_cast<Address>(counter->GetInternalPointer())) {} -ExternalReference::ExternalReference(Top::AddressId id) - : address_(Top::get_address_from_id(id)) {} +ExternalReference::ExternalReference(Isolate::AddressId id, Isolate* isolate) + : address_(isolate->get_address_from_id(id)) {} ExternalReference::ExternalReference(const SCTableReference& table_ref) : address_(table_ref.address()) {} -ExternalReference ExternalReference::perform_gc_function() { - return ExternalReference(Redirect(FUNCTION_ADDR(Runtime::PerformGC))); +ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(Runtime::PerformGC))); } -ExternalReference ExternalReference::fill_heap_number_with_random_function() { - return - ExternalReference(Redirect(FUNCTION_ADDR(V8::FillHeapNumberWithRandom))); +ExternalReference ExternalReference::fill_heap_number_with_random_function( + Isolate* isolate) { + return ExternalReference(Redirect( + isolate, + FUNCTION_ADDR(V8::FillHeapNumberWithRandom))); } -ExternalReference ExternalReference::delete_handle_scope_extensions() { - return ExternalReference(Redirect(FUNCTION_ADDR( - HandleScope::DeleteExtensions))); +ExternalReference ExternalReference::delete_handle_scope_extensions( + Isolate* isolate) { + return ExternalReference(Redirect( + isolate, + FUNCTION_ADDR(HandleScope::DeleteExtensions))); } -ExternalReference ExternalReference::random_uint32_function() { - return ExternalReference(Redirect(FUNCTION_ADDR(V8::Random))); +ExternalReference ExternalReference::random_uint32_function( + Isolate* isolate) { + return ExternalReference(Redirect(isolate, FUNCTION_ADDR(V8::Random))); } -ExternalReference ExternalReference::transcendental_cache_array_address() { - return ExternalReference(TranscendentalCache::cache_array_address()); +ExternalReference ExternalReference::transcendental_cache_array_address( + Isolate* isolate) { + return ExternalReference( + isolate->transcendental_cache()->cache_array_address()); } -ExternalReference ExternalReference::new_deoptimizer_function() { +ExternalReference ExternalReference::new_deoptimizer_function( + Isolate* isolate) { return ExternalReference( - Redirect(FUNCTION_ADDR(Deoptimizer::New))); + Redirect(isolate, FUNCTION_ADDR(Deoptimizer::New))); } -ExternalReference ExternalReference::compute_output_frames_function() { +ExternalReference ExternalReference::compute_output_frames_function( + Isolate* isolate) { return ExternalReference( - Redirect(FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); + Redirect(isolate, FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); } -ExternalReference ExternalReference::global_contexts_list() { - return ExternalReference(Heap::global_contexts_list_address()); +ExternalReference ExternalReference::global_contexts_list(Isolate* isolate) { + return ExternalReference(isolate->heap()->global_contexts_list_address()); } -ExternalReference ExternalReference::keyed_lookup_cache_keys() { - return ExternalReference(KeyedLookupCache::keys_address()); +ExternalReference ExternalReference::keyed_lookup_cache_keys(Isolate* isolate) { + return ExternalReference(isolate->keyed_lookup_cache()->keys_address()); } -ExternalReference ExternalReference::keyed_lookup_cache_field_offsets() { - return ExternalReference(KeyedLookupCache::field_offsets_address()); +ExternalReference ExternalReference::keyed_lookup_cache_field_offsets( + Isolate* isolate) { + return ExternalReference( + isolate->keyed_lookup_cache()->field_offsets_address()); } -ExternalReference ExternalReference::the_hole_value_location() { - return ExternalReference(Factory::the_hole_value().location()); +ExternalReference ExternalReference::the_hole_value_location(Isolate* isolate) { + return ExternalReference(isolate->factory()->the_hole_value().location()); } -ExternalReference ExternalReference::arguments_marker_location() { - return ExternalReference(Factory::arguments_marker().location()); +ExternalReference ExternalReference::arguments_marker_location( + Isolate* isolate) { + return ExternalReference(isolate->factory()->arguments_marker().location()); } -ExternalReference ExternalReference::roots_address() { - return ExternalReference(Heap::roots_address()); +ExternalReference ExternalReference::roots_address(Isolate* isolate) { + return ExternalReference(isolate->heap()->roots_address()); } -ExternalReference ExternalReference::address_of_stack_limit() { - return ExternalReference(StackGuard::address_of_jslimit()); +ExternalReference ExternalReference::address_of_stack_limit(Isolate* isolate) { + return ExternalReference(isolate->stack_guard()->address_of_jslimit()); } -ExternalReference ExternalReference::address_of_real_stack_limit() { - return ExternalReference(StackGuard::address_of_real_jslimit()); +ExternalReference ExternalReference::address_of_real_stack_limit( + Isolate* isolate) { + return ExternalReference(isolate->stack_guard()->address_of_real_jslimit()); } -ExternalReference ExternalReference::address_of_regexp_stack_limit() { - return ExternalReference(RegExpStack::limit_address()); +ExternalReference ExternalReference::address_of_regexp_stack_limit( + Isolate* isolate) { + return ExternalReference(isolate->regexp_stack()->limit_address()); } -ExternalReference ExternalReference::new_space_start() { - return ExternalReference(Heap::NewSpaceStart()); +ExternalReference ExternalReference::new_space_start(Isolate* isolate) { + return ExternalReference(isolate->heap()->NewSpaceStart()); } -ExternalReference ExternalReference::new_space_mask() { - return ExternalReference(reinterpret_cast<Address>(Heap::NewSpaceMask())); +ExternalReference ExternalReference::new_space_mask(Isolate* isolate) { + Address mask = reinterpret_cast<Address>(isolate->heap()->NewSpaceMask()); + return ExternalReference(mask); } -ExternalReference ExternalReference::new_space_allocation_top_address() { - return ExternalReference(Heap::NewSpaceAllocationTopAddress()); +ExternalReference ExternalReference::new_space_allocation_top_address( + Isolate* isolate) { + return ExternalReference(isolate->heap()->NewSpaceAllocationTopAddress()); } -ExternalReference ExternalReference::heap_always_allocate_scope_depth() { - return ExternalReference(Heap::always_allocate_scope_depth_address()); +ExternalReference ExternalReference::heap_always_allocate_scope_depth( + Isolate* isolate) { + Heap* heap = isolate->heap(); + return ExternalReference(heap->always_allocate_scope_depth_address()); } -ExternalReference ExternalReference::new_space_allocation_limit_address() { - return ExternalReference(Heap::NewSpaceAllocationLimitAddress()); +ExternalReference ExternalReference::new_space_allocation_limit_address( + Isolate* isolate) { + return ExternalReference(isolate->heap()->NewSpaceAllocationLimitAddress()); } ExternalReference ExternalReference::handle_scope_level_address() { return ExternalReference(HandleScope::current_level_address()); @@ -714,12 +748,13 @@ ExternalReference ExternalReference::handle_scope_limit_address() { return ExternalReference(HandleScope::current_limit_address()); } -ExternalReference ExternalReference::scheduled_exception_address() { - return ExternalReference(Top::scheduled_exception_address()); +ExternalReference ExternalReference::scheduled_exception_address( + Isolate* isolate) { + return ExternalReference(isolate->scheduled_exception_address()); } ExternalReference ExternalReference::address_of_min_int() { return ExternalReference(reinterpret_cast<void*>( @@ -743,51 +778,67 @@ return ExternalReference(reinterpret_cast<void*>( const_cast<double*>(&DoubleConstant::negative_infinity))); } +ExternalReference ExternalReference::address_of_nan() { + return ExternalReference(reinterpret_cast<void*>( + const_cast<double*>(&DoubleConstant::nan))); +} + + #ifndef V8_INTERPRETED_REGEXP -ExternalReference ExternalReference::re_check_stack_guard_state() { +ExternalReference ExternalReference::re_check_stack_guard_state( + Isolate* isolate) { Address function; #ifdef V8_TARGET_ARCH_X64 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); #elif V8_TARGET_ARCH_IA32 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); #elif V8_TARGET_ARCH_ARM function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); +#elif V8_TARGET_ARCH_MIPS + function = FUNCTION_ADDR(RegExpMacroAssemblerMIPS::CheckStackGuardState); #else UNREACHABLE(); #endif - return ExternalReference(Redirect(function)); + return ExternalReference(Redirect(isolate, function)); } -ExternalReference ExternalReference::re_grow_stack() { +ExternalReference ExternalReference::re_grow_stack(Isolate* isolate) { return ExternalReference( - Redirect(FUNCTION_ADDR(NativeRegExpMacroAssembler::GrowStack))); + Redirect(isolate, FUNCTION_ADDR(NativeRegExpMacroAssembler::GrowStack))); } -ExternalReference ExternalReference::re_case_insensitive_compare_uc16() { +ExternalReference ExternalReference::re_case_insensitive_compare_uc16( + Isolate* isolate) { return ExternalReference(Redirect( + isolate, FUNCTION_ADDR(NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16))); } ExternalReference ExternalReference::re_word_character_map() { return ExternalReference( NativeRegExpMacroAssembler::word_character_map_address()); } -ExternalReference ExternalReference::address_of_static_offsets_vector() { - return ExternalReference(OffsetsVector::static_offsets_vector_address()); +ExternalReference ExternalReference::address_of_static_offsets_vector( + Isolate* isolate) { + return ExternalReference( + OffsetsVector::static_offsets_vector_address(isolate)); } -ExternalReference ExternalReference::address_of_regexp_stack_memory_address() { - return ExternalReference(RegExpStack::memory_address()); +ExternalReference ExternalReference::address_of_regexp_stack_memory_address( + Isolate* isolate) { + return ExternalReference( + isolate->regexp_stack()->memory_address()); } -ExternalReference ExternalReference::address_of_regexp_stack_memory_size() { - return ExternalReference(RegExpStack::memory_size_address()); +ExternalReference ExternalReference::address_of_regexp_stack_memory_size( + Isolate* isolate) { + return ExternalReference(isolate->regexp_stack()->memory_size_address()); } #endif // V8_INTERPRETED_REGEXP @@ -814,10 +865,49 @@ static double mod_two_doubles(double x, double y) { return modulo(x, y); } +static double math_sin_double(double x) { + return sin(x); +} + + +static double math_cos_double(double x) { + return cos(x); +} + + +static double math_log_double(double x) { + return log(x); +} + + +ExternalReference ExternalReference::math_sin_double_function( + Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(math_sin_double), + FP_RETURN_CALL)); +} + + +ExternalReference ExternalReference::math_cos_double_function( + Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(math_cos_double), + FP_RETURN_CALL)); +} + + +ExternalReference ExternalReference::math_log_double_function( + Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(math_log_double), + FP_RETURN_CALL)); +} + + // 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) { @@ -849,18 +939,22 @@ } return pow(x, y); } -ExternalReference ExternalReference::power_double_double_function() { - return ExternalReference(Redirect(FUNCTION_ADDR(power_double_double), +ExternalReference ExternalReference::power_double_double_function( + Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(power_double_double), FP_RETURN_CALL)); } -ExternalReference ExternalReference::power_double_int_function() { - return ExternalReference(Redirect(FUNCTION_ADDR(power_double_int), +ExternalReference ExternalReference::power_double_int_function( + Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(power_double_int), FP_RETURN_CALL)); } static int native_compare_doubles(double y, double x) { @@ -868,11 +962,11 @@ return x < y ? LESS : GREATER; } ExternalReference ExternalReference::double_fp_operation( - Token::Value operation) { + Token::Value operation, Isolate* isolate) { typedef double BinaryFPOperation(double x, double y); BinaryFPOperation* function = NULL; switch (operation) { case Token::ADD: function = &add_two_doubles; @@ -891,31 +985,31 @@ break; default: UNREACHABLE(); } // Passing true as 2nd parameter indicates that they return an fp value. - return ExternalReference(Redirect(FUNCTION_ADDR(function), FP_RETURN_CALL)); + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(function), + FP_RETURN_CALL)); } -ExternalReference ExternalReference::compare_doubles() { - return ExternalReference(Redirect(FUNCTION_ADDR(native_compare_doubles), +ExternalReference ExternalReference::compare_doubles(Isolate* isolate) { + return ExternalReference(Redirect(isolate, + FUNCTION_ADDR(native_compare_doubles), BUILTIN_CALL)); } -ExternalReference::ExternalReferenceRedirector* - ExternalReference::redirector_ = NULL; - - #ifdef ENABLE_DEBUGGER_SUPPORT -ExternalReference ExternalReference::debug_break() { - return ExternalReference(Redirect(FUNCTION_ADDR(Debug::Break))); +ExternalReference ExternalReference::debug_break(Isolate* isolate) { + return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug_Break))); } -ExternalReference ExternalReference::debug_step_in_fp_address() { - return ExternalReference(Debug::step_in_fp_addr()); +ExternalReference ExternalReference::debug_step_in_fp_address( + Isolate* isolate) { + return ExternalReference(isolate->debug()->step_in_fp_addr()); } #endif void PositionsRecorder::RecordPosition(int pos) {