From 7bca61c11d357c78997a59a734f2da4ca6a5eac6 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Tue, 13 Apr 2010 11:59:37 +0000 Subject: [PATCH] Fix build problems on Windows 64-bit by casting. Gave the root register a name for reference. Review URL: http://codereview.chromium.org/1539033 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4397 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/circular-queue-inl.h | 3 ++- src/circular-queue.cc | 6 ++++-- src/heap.cc | 3 ++- src/liveedit.cc | 10 ++++++---- src/profile-generator.cc | 2 +- src/runtime.cc | 13 +++++++------ src/x64/builtins-x64.cc | 2 +- src/x64/macro-assembler-x64.cc | 6 +++--- src/x64/macro-assembler-x64.h | 1 + src/x64/register-allocator-x64-inl.h | 2 +- test/cctest/test-cpu-profiler.cc | 2 +- test/cctest/test-heap.cc | 11 ++++++----- 12 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/circular-queue-inl.h b/src/circular-queue-inl.h index 962b069..90ab0f5 100644 --- a/src/circular-queue-inl.h +++ b/src/circular-queue-inl.h @@ -38,7 +38,8 @@ template CircularQueue::CircularQueue(int desired_buffer_size_in_bytes) : buffer_(NewArray(desired_buffer_size_in_bytes / sizeof(Record))), buffer_end_(buffer_ + desired_buffer_size_in_bytes / sizeof(Record)), - enqueue_semaphore_(OS::CreateSemaphore((buffer_end_ - buffer_) - 1)), + enqueue_semaphore_( + OS::CreateSemaphore(static_cast(buffer_end_ - buffer_) - 1)), enqueue_pos_(buffer_), dequeue_pos_(buffer_) { // To be able to distinguish between a full and an empty queue diff --git a/src/circular-queue.cc b/src/circular-queue.cc index a7c2532..af650de 100644 --- a/src/circular-queue.cc +++ b/src/circular-queue.cc @@ -58,8 +58,10 @@ SamplingCircularQueue::SamplingCircularQueue(int record_size_in_bytes, // updates of positions by different processor cores. const int positions_size = RoundUp(1, kProcessorCacheLineSize) + - RoundUp(sizeof(ProducerPosition), kProcessorCacheLineSize) + - RoundUp(sizeof(ConsumerPosition), kProcessorCacheLineSize); + RoundUp(static_cast(sizeof(ProducerPosition)), + kProcessorCacheLineSize) + + RoundUp(static_cast(sizeof(ConsumerPosition)), + kProcessorCacheLineSize); positions_ = NewArray(positions_size); producer_pos_ = reinterpret_cast( diff --git a/src/heap.cc b/src/heap.cc index 4aaf2d5..b497754 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -2307,7 +2307,8 @@ Object* Heap::CopyCode(Code* code, Vector reloc_info) { Address old_addr = code->address(); - int relocation_offset = code->relocation_start() - old_addr; + size_t relocation_offset = + static_cast(code->relocation_start() - old_addr); Object* result; if (new_obj_size > MaxObjectSizeInPagedSpace()) { diff --git a/src/liveedit.cc b/src/liveedit.cc index 8e02b5d..8c1316b 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -558,8 +558,9 @@ class RelocInfoBuffer { Vector GetResult() { // Return the bytes from pos up to end of buffer. - return Vector(reloc_info_writer_.pos(), - buffer_ + buffer_size_ - reloc_info_writer_.pos()); + int result_size = + static_cast((buffer_ + buffer_size_) - reloc_info_writer_.pos()); + return Vector(reloc_info_writer_.pos(), result_size); } private: @@ -581,7 +582,8 @@ class RelocInfoBuffer { byte* new_buffer = NewArray(new_buffer_size); // Copy the data. - int curently_used_size = buffer_ + buffer_size_ - reloc_info_writer_.pos(); + int curently_used_size = + static_cast(buffer_ + buffer_size_ - reloc_info_writer_.pos()); memmove(new_buffer + new_buffer_size - curently_used_size, reloc_info_writer_.pos(), curently_used_size); @@ -986,7 +988,7 @@ Handle LiveEdit::CheckAndDropActivations( DropActivationsInActiveThread(shared_info_array, result, do_drop); if (error_message != NULL) { // Add error message as an array extra element. - Vector vector_message(error_message, strlen(error_message)); + Vector vector_message(error_message, StrLength(error_message)); Handle str = Factory::NewStringFromAscii(vector_message); SetElement(result, len, str); } diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 46e7aab..b809aab 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -327,7 +327,7 @@ bool CpuProfilesCollection::StartProfiling(String* title, unsigned uid) { CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { - const int title_len = strlen(title); + const int title_len = StrLength(title); CpuProfile* profile = NULL; current_profiles_semaphore_->Wait(); for (int i = current_profiles_.length() - 1; i >= 0; --i) { diff --git a/src/runtime.cc b/src/runtime.cc index 7de610d..3d112b0 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2542,7 +2542,7 @@ static inline int SingleCharIndexOf(Vector string, pattern_char, string.length() - start_index)); if (pos == NULL) return -1; - return pos - string.start(); + return static_cast(pos - string.start()); } for (int i = start_index, n = string.length(); i < n; i++) { if (pattern_char == string[i]) { @@ -2600,7 +2600,7 @@ static int SimpleIndexOf(Vector subject, *complete = true; return -1; } - i = pos - subject.start(); + i = static_cast(pos - subject.start()); } else { if (subject[i] != pattern_first_char) continue; } @@ -2634,7 +2634,7 @@ static int SimpleIndexOf(Vector subject, pattern_first_char, n - i + 1)); if (pos == NULL) return -1; - i = pos - subject.start(); + i = static_cast(pos - subject.start()); } else { if (subject[i] != pattern_first_char) continue; } @@ -6366,7 +6366,7 @@ static const char kMonthInYear[] = { static inline void DateYMDFromTimeAfter1970(int date, int& year, int& month, int& day) { #ifdef DEBUG - int save_date = date; // Need this for ASSERT in the end. + int save_date = date; // Need this for ASSERT in the end. #endif year = 1970 + (4 * date + 2) / kDaysIn4Years; @@ -6382,7 +6382,7 @@ static inline void DateYMDFromTimeAfter1970(int date, static inline void DateYMDFromTimeSlow(int date, int& year, int& month, int& day) { #ifdef DEBUG - int save_date = date; // Need this for ASSERT in the end. + int save_date = date; // Need this for ASSERT in the end. #endif date += kDaysOffset; @@ -9779,7 +9779,8 @@ static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) { // Check if this break point is closer that what was previously found. if (source_position <= statement_position && statement_position - source_position < distance) { - closest_pc = it.rinfo()->pc() - code->instruction_start(); + closest_pc = + static_cast(it.rinfo()->pc() - code->instruction_start()); distance = statement_position - source_position; // Check whether we can't get any closer. if (distance == 0) break; diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 0c5d481..6d332b7 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -1240,7 +1240,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, // Set up the roots register. ExternalReference roots_address = ExternalReference::roots_address(); - __ movq(r13, roots_address); + __ movq(kRootRegister, roots_address); // Current stack contents: // [rsp + 2 * kPointerSize ... ]: Internal frame diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 2781a84..2c47cf8 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -46,17 +46,17 @@ MacroAssembler::MacroAssembler(void* buffer, int size) void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) { - movq(destination, Operand(r13, index << kPointerSizeLog2)); + movq(destination, Operand(kRootRegister, index << kPointerSizeLog2)); } void MacroAssembler::PushRoot(Heap::RootListIndex index) { - push(Operand(r13, index << kPointerSizeLog2)); + push(Operand(kRootRegister, index << kPointerSizeLog2)); } void MacroAssembler::CompareRoot(Register with, Heap::RootListIndex index) { - cmpq(with, Operand(r13, index << kPointerSizeLog2)); + cmpq(with, Operand(kRootRegister, index << kPointerSizeLog2)); } diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index b5bb636..dabb764 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -37,6 +37,7 @@ namespace internal { // a spare register). The register isn't callee save, and not used by the // function calling convention. static const Register kScratchRegister = { 10 }; // r10. +static const Register kRootRegister = { 13 }; // r13 // Convenience for platform-independent signatures. typedef Operand MemOperand; diff --git a/src/x64/register-allocator-x64-inl.h b/src/x64/register-allocator-x64-inl.h index d630b33..c7c18b3 100644 --- a/src/x64/register-allocator-x64-inl.h +++ b/src/x64/register-allocator-x64-inl.h @@ -38,7 +38,7 @@ namespace internal { bool RegisterAllocator::IsReserved(Register reg) { return reg.is(rsp) || reg.is(rbp) || reg.is(rsi) || - reg.is(kScratchRegister); + reg.is(kScratchRegister) || reg.is(kRootRegister); } diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 4e4cf28..81d981e 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -95,7 +95,7 @@ TEST(CodeEvents) { i::HandleScope scope; const char* aaa_str = "aaa"; i::Handle aaa_name = i::Factory::NewStringFromAscii( - i::Vector(aaa_str, strlen(aaa_str))); + i::Vector(aaa_str, i::StrLength(aaa_str))); processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, *aaa_name, i::Heap::empty_string(), diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc index bfadd20..41be8c0 100644 --- a/test/cctest/test-heap.cc +++ b/test/cctest/test-heap.cc @@ -821,19 +821,20 @@ TEST(LargeObjectSpaceContains) { Page* page = Page::FromAddress(current_top); Address current_page = page->address(); Address next_page = current_page + Page::kPageSize; - int bytes_to_page = next_page - current_top; + int bytes_to_page = static_cast(next_page - current_top); if (bytes_to_page <= FixedArray::kHeaderSize) { // Alas, need to cross another page to be able to // put desired value. next_page += Page::kPageSize; - bytes_to_page = next_page - current_top; + bytes_to_page = static_cast(next_page - current_top); } CHECK(bytes_to_page > FixedArray::kHeaderSize); int* is_normal_page_ptr = &Page::FromAddress(next_page)->is_normal_page; Address is_normal_page_addr = reinterpret_cast
(is_normal_page_ptr); - int bytes_to_allocate = (is_normal_page_addr - current_top) + kPointerSize; + int bytes_to_allocate = + static_cast(is_normal_page_addr - current_top) + kPointerSize; int n_elements = (bytes_to_allocate - FixedArray::kHeaderSize) / kPointerSize; @@ -917,7 +918,7 @@ TEST(Regression39128) { } // Step 3: now allocate fixed array and JSObject to fill the whole new space. - int to_fill = *limit_addr - *top_addr - object_size; + int to_fill = static_cast(*limit_addr - *top_addr - object_size); int fixed_array_len = LenFromSize(to_fill); CHECK(fixed_array_len < FixedArray::kMaxLength); @@ -935,7 +936,7 @@ TEST(Regression39128) { // Create a reference to object in new space in jsobject. jsobject->FastPropertyAtPut(-1, array); - CHECK_EQ(0L, (*limit_addr - *top_addr)); + CHECK_EQ(0, static_cast(*limit_addr - *top_addr)); // Step 4: clone jsobject, but force always allocate first to create a clone // in old pointer space. -- 2.7.4