Search
j0ke.net Open Build Service
>
Projects
>
server:database
:
mongodb
:
2.4
>
mongodb
> mongodb_2_4_10_update_v8_3_14_to_ppc_branch_cid_dea1f48.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File mongodb_2_4_10_update_v8_3_14_to_ppc_branch_cid_dea1f48.patch of Package mongodb
From: Michel Normand <normand@linux.vnet.ibm.com> Subject: mongodb 2 4 10 update v8 3 14 to ppc branch cid dea1f48 Date: Mon, 09 Feb 2015 14:28:15 +0100 mongodb_2_4_10 update src/third_party/v8-3.14/ to ppc branch cid dea1f48 from github.com/andrewlow/v8ppc.git cid dea1f48 git head of 3.14-ppc branch cid 7d1b8b5 git head of libv8-3.14 branch cid 8418fb6 associated to previous patch mongodb_2_4_10_add_v8_3_14.patch to as detailed below: === $git clone https://github.com/andrewlow/v8ppc.git $cd v8ppc $gco 3.14-ppc $gbr |grep \* * 3.14-ppc $gta | grep 3.14-ppc | | | | * dea1f48 (HEAD, tag: export-3.14-to-node-2014-12-22, origin/3.14-ppc, 3.14-ppc) PPC: perf enhancement: use bctrl for calls (vs blrl). ... === export cid=dea1f48 export tmpdir=/tmp/third_party/v8-3.14_cid_$cid export tarfile=/tmp/v8-3.14_cid_$cid.tar $git archive $cid >$tarfile === $mkdir $tmpdir && cd $tmpdir && tar -xf $tarfile $rm -rf benchmarks/ build/ codereview.settings DEPS WATCHLISTS Makefile Makefile.android Makefile.nacl samples/ test/ tools/ .gitignore === ... $cd mongodb.tmp/mongodb-src-r2.4.10 [normand@mnoW520:~/work/mongodb.tmp/mongodb-src-r2.4.10] $quilt applied mongodb_2_4_10_add_v8_3_14.patch.bz2 mongodb_2_4_10_update_v8_3_14_to_cid_7d1b8b5.patch.bz2 $quilt new mongodb_2_4_10_update_v8_3_14_to_ppc_branch_cid_dea1f48.patch $for xx in $(cd $tmpdir; find ./ ! -type d); do quilt add src/third_party/v8-3.14/$xx ;done $cp -rp $tmpdir/* src/third_party/v8-3.14/ $quilt refresh === Signed-off-by: Michel Normand <normand@linux.vnet.ibm.com> --- src/third_party/v8-3.14/ChangeLog | 4 src/third_party/v8-3.14/LICENSE.valgrind | 10 src/third_party/v8-3.14/README.md | 10 src/third_party/v8-3.14/aix_gyp.patch | 26 - src/third_party/v8-3.14/src/assembler.h | 4 src/third_party/v8-3.14/src/debug.cc | 2 src/third_party/v8-3.14/src/heap.h | 2 src/third_party/v8-3.14/src/hydrogen.cc | 4 src/third_party/v8-3.14/src/platform-aix.cc | 53 ++-- src/third_party/v8-3.14/src/platform-posix.cc | 19 + src/third_party/v8-3.14/src/ppc/assembler-ppc.cc | 132 +++++++--- src/third_party/v8-3.14/src/ppc/assembler-ppc.h | 7 src/third_party/v8-3.14/src/ppc/builtins-ppc.cc | 2 src/third_party/v8-3.14/src/ppc/code-stubs-ppc.cc | 9 src/third_party/v8-3.14/src/ppc/debug-ppc.cc | 10 src/third_party/v8-3.14/src/ppc/deoptimizer-ppc.cc | 4 src/third_party/v8-3.14/src/ppc/disasm-ppc.cc | 40 ++- src/third_party/v8-3.14/src/ppc/full-codegen-ppc.cc | 6 src/third_party/v8-3.14/src/ppc/ic-ppc.cc | 30 +- src/third_party/v8-3.14/src/ppc/lithium-codegen-ppc.cc | 58 ++-- src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.cc | 45 ++- src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.h | 4 src/third_party/v8-3.14/src/ppc/regexp-macro-assembler-ppc.cc | 6 src/third_party/v8-3.14/src/ppc/simulator-ppc.cc | 116 +++++++- src/third_party/v8-3.14/src/ppc/simulator-ppc.h | 3 src/third_party/v8-3.14/src/ppc/stub-cache-ppc.cc | 2 src/third_party/v8-3.14/src/third_party/valgrind/valgrind.h | 44 +-- 27 files changed, 470 insertions(+), 182 deletions(-) Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/ChangeLog =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/ChangeLog +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/ChangeLog @@ -1174,7 +1174,7 @@ 2011-12-21: Version 3.8.2 - Add max optimization flag to v8 gyp build to ensure V8 is always built + Add max optimization flag to v8 gyp build to ensure V8 is always built fully optimized in Chrome. MIPS: Bring MIPS to parity with other platforms. @@ -1193,7 +1193,7 @@ Fixed handling of arrays in DefineOwnProperty. (issue 1756) - Sync parser and preparser on do-while and return statements. + Sync parser and preparser on do-while and return statements. (issue 1856) Fixed another corner case for DefineOwnProperty on arrays (issue 1756). Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/LICENSE.valgrind =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/LICENSE.valgrind +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/LICENSE.valgrind @@ -20,16 +20,16 @@ are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product +2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written +4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/README.md =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/README.md +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/README.md @@ -3,8 +3,12 @@ v8ppc Port of Google V8 javascript engine to PowerPC - PowerLinux and AIX. -This branch of the code (libv8-3.14) is intended to match the 3.14.5.8 -level of V8 that is used by the libv8 library built as part of Ubuntu +August 9th 98% of the tests were passing. (with crankshaft!) -http://packages.ubuntu.com/source/trusty/libv8-3.14 +Compile code:<br><code> +make dependencies; make -j8 ppc +</code> +Test code:<br><code> +tools/run-tests.py -j 12 --progress=dots --no-presubmit --arch-and-mode=ppc.debug --junitout v8tests-junit.xml +</code> Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/aix_gyp.patch =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/aix_gyp.patch +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/aix_gyp.patch @@ -6,30 +6,30 @@ return 'freebsd' + if sys.platform.startswith('aix'): + return 'aix' - + return 'linux' - + --- build/gyp/pylib/gyp/generator/make.py +++ build/gyp/pylib/gyp/generator/make.py @@ -200,6 +200,21 @@ """ - - + + + LINK_COMMANDS_AIX = """\ + quiet_cmd_alink = AR($(TOOLSET)) $@ + cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) -+ ++ + quiet_cmd_link = LINK($(TOOLSET)) $@ + cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -+ ++ + quiet_cmd_solink = SOLINK($(TOOLSET)) $@ + cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) -+ ++ + quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ + cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) + """ -+ -+ ++ ++ # Header of toplevel Makefile. # This should go into the build tree, but it's easier to keep it here for now. SHARED_HEADER = ("""\ @@ -39,14 +39,14 @@ @@ -1933,6 +1948,10 @@ cc_command=cc_host): arflags_host = 'crsT' - + + if flavor == 'aix': + arflags_target = '-Xany ' + arflags_target + arflags_host = '-Xany ' + arflags_host -+ ++ return { 'ARFLAGS.target': arflags_target, 'ARFLAGS.host': arflags_host } - + --- build/gyp/pylib/gyp/generator/make.py +++ build/gyp/pylib/gyp/generator/make.py @@ -2026,6 +2045,10 @@ @@ -58,5 +58,5 @@ + header_params.update({ + 'link_commands': LINK_COMMANDS_AIX, }) - + header_params.update(RunSystemTests(flavor)) Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/assembler.h =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/assembler.h +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/assembler.h @@ -838,6 +838,10 @@ inline bool is_int16(intptr_t x) { retu inline bool is_int18(intptr_t x) { return is_intn(x, 18); } inline bool is_int24(intptr_t x) { return is_intn(x, 24); } inline bool is_int26(intptr_t x) { return is_intn(x, 26); } +#if V8_HOST_ARCH_64_BIT && !(V8_TARGET_ARCH_X64) +inline bool is_int32(intptr_t x) { return is_intn(x, 32); } +inline bool is_int48(intptr_t x) { return is_intn(x, 48); } +#endif inline bool is_uintn(intptr_t x, int n) { Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/debug.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/debug.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/debug.cc @@ -2308,7 +2308,7 @@ void Debug::SetAfterBreakTarget(JavaScri // Handle the jump to continue execution after break point depending on the // break location. if (at_js_return) { - // If the break point as return is still active jump to the corresponding + // If the break point at return is still active jump to the corresponding // place in the original code. If not the break point was removed during // break point processing. if (break_at_js_return_active) { Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/heap.h =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/heap.h +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/heap.h @@ -1730,7 +1730,7 @@ class Heap { int scan_on_scavenge_pages_; -#if defined(V8_TARGET_ARCH_X64) +#if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_PPC64) static const int kMaxObjectSizeInNewSpace = 1024*KB; #else static const int kMaxObjectSizeInNewSpace = 512*KB; Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/hydrogen.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/hydrogen.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/hydrogen.cc @@ -5255,6 +5255,10 @@ static bool ComputeLoadStoreField(Handle Handle<String> name, LookupResult* lookup, bool is_store) { + if (type->has_named_interceptor()) { + lookup->InterceptorResult(NULL); + return false; + } // If we directly find a field, the access can be inlined. type->LookupDescriptor(NULL, *name, lookup); if (lookup->IsField()) return true; Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/platform-aix.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/platform-aix.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/platform-aix.cc @@ -60,6 +60,31 @@ namespace v8 { namespace internal { +static inline void *mmapHelper(size_t len, int prot, int flags, + int fildes, off_t off) { + void *addr = OS::GetRandomMmapAddr(); +#if V8_TARGET_ARCH_PPC64 + if (addr) { + // We must use MAP_FIXED here to avoid the 0x07000000_00000000 + // range, which causes loss of precision if addresses are + // converted to double precision numbers. + ASSERT(!(flags & MAP_VARIABLE)); + void* mbase; + for (int i = 0; i < 10; i++) { + mbase = mmap(addr, len, prot, flags | MAP_FIXED, fildes, off); + if (mbase != MAP_FAILED) return mbase; + // Try again with a different random address. + addr = OS::GetRandomMmapAddr(); + } + } + // Fall through if we can't get an address in the range we want + // after multiple attempts -- just let the system decide (without + // MAP_FIXED this time). +#endif + return mmap(addr, len, prot, flags, fildes, off); +} + + // 0 is never a valid thread id on AIX since tids and pids share a // name space and pid 0 is used to kill the group (see man 2 kill). static const pthread_t kNoThread = (pthread_t) 0; @@ -154,7 +179,7 @@ void* OS::Allocate(const size_t requeste bool executable) { const size_t msize = RoundUp(requested, getpagesize()); int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); - void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + void* mbase = mmapHelper(msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mbase == MAP_FAILED) { LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); @@ -221,7 +246,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFi int size = ftell(file); void* memory = - mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); + mmapHelper(size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); return new PosixMemoryMappedFile(file, memory, size); } @@ -236,7 +261,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFi return NULL; } void* memory = - mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); + mmapHelper(size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); return new PosixMemoryMappedFile(file, memory, size); } @@ -318,12 +343,11 @@ VirtualMemory::VirtualMemory(size_t size ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); size_t request_size = RoundUp(size + alignment, static_cast<intptr_t>(OS::AllocateAlignment())); - void* reservation = mmap(OS::GetRandomMmapAddr(), - request_size, - PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, - kMmapFd, - kMmapFdOffset); + void* reservation = mmapHelper(request_size, + PROT_NONE, + MAP_PRIVATE | MAP_ANONYMOUS, + kMmapFd, + kMmapFdOffset); if (reservation == MAP_FAILED) return; Address base = static_cast<Address>(reservation); @@ -390,12 +414,11 @@ bool VirtualMemory::Guard(void* address) void* VirtualMemory::ReserveRegion(size_t size) { - void* result = mmap(OS::GetRandomMmapAddr(), - size, - PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, - kMmapFd, - kMmapFdOffset); + void* result = mmapHelper(size, + PROT_NONE, + MAP_PRIVATE | MAP_ANONYMOUS, + kMmapFd, + kMmapFdOffset); if (result == MAP_FAILED) return NULL; Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/platform-posix.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/platform-posix.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/platform-posix.cc @@ -103,14 +103,31 @@ void* OS::GetRandomMmapAddr() { // CpuFeatures::Probe. We don't care about randomization in this case because // the code page is immediately freed. if (isolate != NULL) { -#ifdef V8_TARGET_ARCH_X64 +#ifdef V8_HOST_ARCH_64_BIT uint64_t rnd1 = V8::RandomPrivate(isolate); uint64_t rnd2 = V8::RandomPrivate(isolate); uint64_t raw_addr = (rnd1 << 32) ^ rnd2; +#endif +#ifdef V8_TARGET_ARCH_X64 // Currently available CPUs have 48 bits of virtual addressing. Truncate // the hint address to 46 bits to give the kernel a fighting chance of // fulfilling our placement request. raw_addr &= V8_UINT64_C(0x3ffffffff000); +#elif defined(V8_TARGET_ARCH_PPC64) +# ifdef _AIX + // AIX: 64 bits of virtual addressing, but we limit address range to: + // a) minimize Segment Lookaside Buffer (SLB) misses and + // b) avoid losing precision if address is stored as a double. + raw_addr &= V8_UINT64_C(0x3ffff000); + // Use extra address space to isolate the mmap regions. + raw_addr += V8_UINT64_C(0x400000000000); +# elif __BYTE_ORDER == __BIG_ENDIAN + // Big-endian Linux: 44 bits of virtual addressing. + raw_addr &= V8_UINT64_C(0x03fffffff000); +# else + // Little-endian Linux: 48 bits of virtual addressing. + raw_addr &= V8_UINT64_C(0x3ffffffff000); +# endif #else uint32_t raw_addr = V8::RandomPrivate(isolate); // The range 0x20000000 - 0x60000000 is relatively unpopulated across a Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/assembler-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/assembler-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/assembler-ppc.cc @@ -714,18 +714,26 @@ void Assembler::blr() { } // Pseudo op - branch to count register -- used for "jump" -void Assembler::bcr() { +void Assembler::bctr() { bcctr(BA, LeaveLK); } +void Assembler::bctrl() { + bcctr(BA, SetLK); +} + void Assembler::bc(int branch_offset, BOfield bo, int condition_bit, LKBit lk) { - positions_recorder()->WriteRecordedPositions(); + if (lk == SetLK) { + positions_recorder()->WriteRecordedPositions(); + } ASSERT(is_int16(branch_offset)); emit(BCX | bo | condition_bit*B16 | (kImm16Mask & branch_offset) | lk); } void Assembler::b(int branch_offset, LKBit lk) { - positions_recorder()->WriteRecordedPositions(); + if (lk == SetLK) { + positions_recorder()->WriteRecordedPositions(); + } ASSERT((branch_offset & 3) == 0); int imm26 = branch_offset; ASSERT(is_int26(imm26)); @@ -949,6 +957,43 @@ void Assembler::cmpl(Register src1, Regi src2.code()*B11); } + +void Assembler::cmpwi(Register src1, const Operand& src2, CRegister cr) { + intptr_t imm16 = src2.imm_; + int L = 0; + ASSERT(is_int16(imm16)); + ASSERT(cr.code() >= 0 && cr.code() <= 7); + imm16 &= kImm16Mask; + emit(CMPI | cr.code()*B23 | L*B21 | src1.code()*B16 | imm16); +} + + +void Assembler::cmplwi(Register src1, const Operand& src2, CRegister cr) { + uintptr_t uimm16 = src2.imm_; + int L = 0; + ASSERT(is_uint16(uimm16)); + ASSERT(cr.code() >= 0 && cr.code() <= 7); + uimm16 &= kImm16Mask; + emit(CMPLI | cr.code()*B23 | L*B21 | src1.code()*B16 | uimm16); +} + + +void Assembler::cmpw(Register src1, Register src2, CRegister cr) { + int L = 0; + ASSERT(cr.code() >= 0 && cr.code() <= 7); + emit(EXT2 | CMP | cr.code()*B23 | L*B21 | src1.code()*B16 | + src2.code()*B11); +} + + +void Assembler::cmplw(Register src1, Register src2, CRegister cr) { + int L = 0; + ASSERT(cr.code() >= 0 && cr.code() <= 7); + emit(EXT2 | CMPL | cr.code()*B23 | L*B21 | src1.code()*B16 | + src2.code()*B11); +} + + // Pseudo op - load immediate void Assembler::li(Register dst, const Operand &imm) { d_form(ADDI, dst, r0, imm.imm_, true); @@ -1301,42 +1346,73 @@ void Assembler::function_descriptor() { // Todo - break this dependency so we can optimize mov() in general // and only use the generic version when we require a fixed sequence void Assembler::mov(Register dst, const Operand& src) { - BlockTrampolinePoolScope block_trampoline_pool(this); if (src.rmode_ != RelocInfo::NONE) { // some form of relocation needed RecordRelocInfo(src.rmode_, src.imm_); } -#if V8_TARGET_ARCH_PPC64 - int64_t value = src.immediate(); - int32_t hi_32 = static_cast<int64_t>(value) >> 32; - int32_t lo_32 = static_cast<int32_t>(value); - int hi_word = static_cast<int>(hi_32) >> 16; - int lo_word = static_cast<int>(hi_32) & 0xFFFF; - lis(dst, Operand(SIGN_EXT_IMM16(hi_word))); - ori(dst, dst, Operand(lo_word)); - sldi(dst, dst, Operand(32)); - hi_word = (static_cast<int>(lo_32) >> 16) & 0xFFFF; - lo_word = static_cast<int>(lo_32) & 0xFFFF; - oris(dst, dst, Operand(hi_word)); - ori(dst, dst, Operand(lo_word)); -#else - int value = src.immediate(); - if (!is_trampoline_pool_blocked()) { + intptr_t value = src.immediate(); + bool canOptimize = (src.rmode_ == RelocInfo::NONE && + !is_trampoline_pool_blocked()); + + if (canOptimize) { if (is_int16(value)) { li(dst, Operand(value)); - return; + } else { + uint16_t u16; +#if V8_TARGET_ARCH_PPC64 + if (is_int32(value)) { +#endif + lis(dst, Operand(value >> 16)); +#if V8_TARGET_ARCH_PPC64 + } else { + if (is_int48(value)) { + li(dst, Operand(value >> 32)); + } else { + lis(dst, Operand(value >> 48)); + u16 = ((value >> 32) & 0xffff); + if (u16) { + ori(dst, dst, Operand(u16)); + } + } + sldi(dst, dst, Operand(32)); + u16 = ((value >> 16) & 0xffff); + if (u16) { + oris(dst, dst, Operand(u16)); + } + } +#endif + u16 = (value & 0xffff); + if (u16) { + ori(dst, dst, Operand(u16)); + } } - } - int hi_word = static_cast<int>(value) >> 16; - int lo_word = static_cast<int>(value) & 0XFFFF; - - lis(dst, Operand(SIGN_EXT_IMM16(hi_word))); - if ((!is_trampoline_pool_blocked()) && (lo_word == 0)) { return; } - ori(dst, dst, Operand(lo_word)); + + ASSERT(!canOptimize); + + { + BlockTrampolinePoolScope block_trampoline_pool(this); +#if V8_TARGET_ARCH_PPC64 + int32_t hi_32 = static_cast<int32_t>(value >> 32); + int32_t lo_32 = static_cast<int32_t>(value); + int hi_word = static_cast<int>(hi_32 >> 16); + int lo_word = static_cast<int>(hi_32 & 0xffff); + lis(dst, Operand(SIGN_EXT_IMM16(hi_word))); + ori(dst, dst, Operand(lo_word)); + sldi(dst, dst, Operand(32)); + hi_word = static_cast<int>(((lo_32 >> 16) & 0xffff)); + lo_word = static_cast<int>(lo_32 & 0xffff); + oris(dst, dst, Operand(hi_word)); + ori(dst, dst, Operand(lo_word)); +#else + int hi_word = static_cast<int>(value >> 16); + int lo_word = static_cast<int>(value & 0xffff); + lis(dst, Operand(SIGN_EXT_IMM16(hi_word))); + ori(dst, dst, Operand(lo_word)); #endif + } } // Special register instructions Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/assembler-ppc.h =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/assembler-ppc.h +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/assembler-ppc.h @@ -735,7 +735,8 @@ class Assembler : public AssemblerBase { void b(int branch_offset, LKBit lk); void bcctr(BOfield bo, LKBit lk); - void bcr(); + void bctr(); + void bctrl(); // Convenience branch instructions using labels void b(Label* L, LKBit lk = LeaveLK) { @@ -876,6 +877,8 @@ class Assembler : public AssemblerBase { void xor_(Register dst, Register src1, Register src2, RCBit rc = LeaveRC); void cmpi(Register src1, const Operand& src2, CRegister cr = cr7); void cmpli(Register src1, const Operand& src2, CRegister cr = cr7); + void cmpwi(Register src1, const Operand& src2, CRegister cr = cr7); + void cmplwi(Register src1, const Operand& src2, CRegister cr = cr7); void li(Register dst, const Operand& src); void lis(Register dst, const Operand& imm); void mr(Register dst, Register src); @@ -960,6 +963,8 @@ class Assembler : public AssemblerBase { void cmp(Register src1, Register src2, CRegister cr = cr7); void cmpl(Register src1, Register src2, CRegister cr = cr7); + void cmpw(Register src1, Register src2, CRegister cr = cr7); + void cmplw(Register src1, Register src2, CRegister cr = cr7); void mov(Register dst, const Operand& src); Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/builtins-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/builtins-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/builtins-ppc.cc @@ -727,7 +727,7 @@ static void GenerateTailCallToSharedCode __ LoadP(r5, FieldMemOperand(r5, SharedFunctionInfo::kCodeOffset)); __ addi(r5, r5, Operand(Code::kHeaderSize - kHeapObjectTag)); __ mtctr(r5); - __ bcr(); + __ bctr(); } Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/code-stubs-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/code-stubs-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/code-stubs-ppc.cc @@ -675,6 +675,7 @@ void FloatingPointHelper::ConvertIntToDo #endif // load into FPR + __ nop(); // LHS/RAW optimization __ lfd(double_dst, MemOperand(sp, 0)); __ addi(sp, sp, Operand(8)); // restore stack @@ -707,6 +708,7 @@ void FloatingPointHelper::ConvertUnsigne #endif // load into FPR + __ nop(); // LHS/RAW optimization __ lfd(double_dst, MemOperand(sp, 0)); __ addi(sp, sp, Operand(8)); // restore stack @@ -737,6 +739,7 @@ void FloatingPointHelper::ConvertIntToFl #endif // load sign-extended src into FPR + __ nop(); // LHS/RAW optimization __ lfd(dst, MemOperand(sp, 0)); __ addi(sp, sp, Operand(8)); // restore stack @@ -3925,8 +3928,8 @@ void JSEntryStub::GenerateBody(MacroAsse // Branch and link to JSEntryTrampoline. // the address points to the start of the code object, skip the header __ addi(r0, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ mtlr(r0); - __ bclr(BA, SetLK); // make the call + __ mtctr(r0); + __ bctrl(); // make the call // Unlink this frame from the handler chain. __ PopTryHandler(); @@ -3964,7 +3967,7 @@ void JSEntryStub::GenerateBody(MacroAsse __ LoadP(r0, MemOperand(sp, kStackFrameLRSlot * kPointerSize)); __ mtctr(r0); - __ bcr(); + __ bctr(); } Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/debug-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/debug-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/debug-ppc.cc @@ -74,12 +74,13 @@ void BreakLocationIterator::SetDebugBrea // bkpt // CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); + Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); // printf("SetDebugBreakAtReturn: pc=%08x\n", (unsigned int)rinfo()->pc()); patcher.masm()->mov(v8::internal::r0, Operand(reinterpret_cast<intptr_t>( Isolate::Current()->debug()->debug_break_return()->entry()))); - patcher.masm()->mtlr(v8::internal::r0); - patcher.masm()->bclr(BA, SetLK); + patcher.masm()->mtctr(v8::internal::r0); + patcher.masm()->bctrl(); patcher.masm()->bkpt(0); } @@ -126,12 +127,13 @@ void BreakLocationIterator::SetDebugBrea // The 64bit sequence is +3 instructions longer for the load // CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); + Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); // printf("SetDebugBreakAtSlot: pc=%08x\n", (unsigned int)rinfo()->pc()); patcher.masm()->mov(v8::internal::r0, Operand(reinterpret_cast<intptr_t>( Isolate::Current()->debug()->debug_break_slot()->entry()))); - patcher.masm()->mtlr(v8::internal::r0); - patcher.masm()->bclr(BA, SetLK); + patcher.masm()->mtctr(v8::internal::r0); + patcher.masm()->bctrl(); } Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/deoptimizer-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/deoptimizer-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/deoptimizer-ppc.cc @@ -190,6 +190,7 @@ void Deoptimizer::PatchStackCheckCodeAt( #if V8_TARGET_ARCH_PPC64 CodePatcher patcher(pc_after - 8 * kInstrSize, 6); + Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); // Assemble the 64 bit value from the five part load and verify // that it is the stack guard code @@ -204,6 +205,7 @@ void Deoptimizer::PatchStackCheckCodeAt( (Memory::uint32_at(pc_after - 3 * kInstrSize) & 0xFFFF); #else CodePatcher patcher(pc_after - 5 * kInstrSize, 3); + Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); // Assemble the 32 bit value from the two part load and verify // that it is the stack guard code @@ -258,6 +260,7 @@ void Deoptimizer::RevertStackCheckCodeAt #if V8_TARGET_ARCH_PPC64 // Replace NOP with conditional jump. CodePatcher patcher(pc_after - 8 * kInstrSize, 6); + Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); if (FLAG_count_based_interrupts) { patcher.masm()->bc(+68, BF, v8::internal::Assembler::encode_crbit(cr7, CR_LT)); // bge @@ -272,6 +275,7 @@ void Deoptimizer::RevertStackCheckCodeAt #else // Replace NOP with conditional jump. CodePatcher patcher(pc_after - 5 * kInstrSize, 3); + Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); if (FLAG_count_based_interrupts) { patcher.masm()->bc(+36, BF, v8::internal::Assembler::encode_crbit(cr7, CR_LT)); // bge Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/disasm-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/disasm-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/disasm-ppc.cc @@ -643,7 +643,15 @@ void Decoder::DecodeExt2(Instruction* in // ?? are all of these xo_form? switch (instr->Bits(9, 1) << 1) { case CMP: { - Format(instr, "cmp 'ra, 'rb"); +#if V8_TARGET_ARCH_PPC64 + if (instr->Bit(21)) { +#endif + Format(instr, "cmp 'ra, 'rb"); +#if V8_TARGET_ARCH_PPC64 + } else { + Format(instr, "cmpw 'ra, 'rb"); + } +#endif break; } case SLWX: { @@ -683,7 +691,15 @@ void Decoder::DecodeExt2(Instruction* in break; } case CMPL: { - Format(instr, "cmpl 'ra, 'rb"); +#if V8_TARGET_ARCH_PPC64 + if (instr->Bit(21)) { +#endif + Format(instr, "cmpl 'ra, 'rb"); +#if V8_TARGET_ARCH_PPC64 + } else { + Format(instr, "cmplw 'ra, 'rb"); + } +#endif break; } case NEGX: { @@ -977,11 +993,27 @@ int Decoder::InstructionDecode(byte* ins break; } case CMPLI: { - Format(instr, "cmpli 'ra, 'uint16"); +#if V8_TARGET_ARCH_PPC64 + if (instr->Bit(21)) { +#endif + Format(instr, "cmpli 'ra, 'uint16"); +#if V8_TARGET_ARCH_PPC64 + } else { + Format(instr, "cmplwi 'ra, 'uint16"); + } +#endif break; } case CMPI: { - Format(instr, "cmpi 'ra, 'int16"); +#if V8_TARGET_ARCH_PPC64 + if (instr->Bit(21)) { +#endif + Format(instr, "cmpi 'ra, 'int16"); +#if V8_TARGET_ARCH_PPC64 + } else { + Format(instr, "cmpwi 'ra, 'int16"); + } +#endif break; } case ADDIC: { Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/full-codegen-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/full-codegen-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/full-codegen-ppc.cc @@ -3711,8 +3711,8 @@ void FullCodeGenerator::EmitFastAsciiArr // zero. __ cmpi(ip, Operand::Zero()); __ bne(&bailout); - __ TestSignBit32(scratch2, r0); - __ bne(&bailout, cr0); + __ cmpwi(scratch2, Operand::Zero()); + __ blt(&bailout); #endif __ AddAndCheckForOverflow(string_length, string_length, scratch2, @@ -4572,7 +4572,7 @@ void FullCodeGenerator::ExitFinallyBlock __ mov(ip, Operand(masm_->CodeObject())); __ add(ip, ip, r4); __ mtctr(ip); - __ bcr(); + __ bctr(); } Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/ic-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/ic-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/ic-ppc.cc @@ -817,8 +817,7 @@ static MemOperand GenerateMappedArgument __ LoadP(scratch1, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); __ SmiToPtrArrayOffset(scratch3, scratch2); __ addi(scratch3, scratch3, Operand(Context::kHeaderSize - kHeapObjectTag)); - __ add(scratch1, scratch1, scratch3); - return MemOperand(scratch1); + return MemOperand(scratch1, scratch3); } @@ -844,8 +843,7 @@ static MemOperand GenerateUnmappedArgume __ addi(scratch, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); - __ add(backing_store, backing_store, scratch); - return MemOperand(backing_store); + return MemOperand(backing_store, scratch); } @@ -858,13 +856,13 @@ void KeyedLoadIC::GenerateNonStrictArgum Label slow, notin; MemOperand mapped_location = GenerateMappedArgumentsLookup(masm, r4, r3, r5, r6, r7, ¬in, &slow); - __ LoadP(r3, mapped_location); + __ LoadPX(r3, mapped_location); __ Ret(); __ bind(¬in); // The unmapped lookup expects that the parameter map is in r5. MemOperand unmapped_location = GenerateUnmappedArgumentsLookup(masm, r3, r5, r6, &slow); - __ LoadP(r5, unmapped_location); + __ LoadPX(r5, unmapped_location); __ LoadRoot(r6, Heap::kTheHoleValueRootIndex); __ cmp(r5, r6); __ beq(&slow); @@ -885,19 +883,23 @@ void KeyedStoreIC::GenerateNonStrictArgu Label slow, notin; MemOperand mapped_location = GenerateMappedArgumentsLookup(masm, r5, r4, r6, r7, r8, ¬in, &slow); - __ StoreP(r3, mapped_location); - __ mr(r9, r6); // r6 is modified by GenerateMappedArgumentsLookup + Register mapped_base = mapped_location.ra(); + Register mapped_offset = mapped_location.rb(); + __ StorePX(r3, mapped_location); + __ add(r9, mapped_base, mapped_offset); __ mr(r22, r3); - __ RecordWrite(r6, r9, r22, kLRHasNotBeenSaved, kDontSaveFPRegs); + __ RecordWrite(mapped_base, r9, r22, kLRHasNotBeenSaved, kDontSaveFPRegs); __ Ret(); __ bind(¬in); // The unmapped lookup expects that the parameter map is in r6. MemOperand unmapped_location = GenerateUnmappedArgumentsLookup(masm, r4, r6, r7, &slow); - __ StoreP(r3, unmapped_location); - __ mr(r9, r6); // r6 is modified by GenerateUnmappedArgumentsLookup + Register unmapped_base = unmapped_location.ra(); + Register unmapped_offset = unmapped_location.rb(); + __ StorePX(r3, unmapped_location); + __ add(r9, unmapped_base, unmapped_offset); __ mr(r22, r3); - __ RecordWrite(r6, r9, r22, kLRHasNotBeenSaved, kDontSaveFPRegs); + __ RecordWrite(unmapped_base, r9, r22, kLRHasNotBeenSaved, kDontSaveFPRegs); __ Ret(); __ bind(&slow); GenerateMiss(masm, false); @@ -915,13 +917,13 @@ void KeyedCallIC::GenerateNonStrictArgum __ LoadP(r4, MemOperand(sp, argc * kPointerSize), r0); MemOperand mapped_location = GenerateMappedArgumentsLookup(masm, r4, r5, r6, r7, r8, ¬in, &slow); - __ LoadP(r4, mapped_location); + __ LoadPX(r4, mapped_location); GenerateFunctionTailCall(masm, argc, &slow, r6); __ bind(¬in); // The unmapped lookup expects that the parameter map is in r6. MemOperand unmapped_location = GenerateUnmappedArgumentsLookup(masm, r5, r6, r7, &slow); - __ LoadP(r4, unmapped_location); + __ LoadPX(r4, unmapped_location); __ LoadRoot(r6, Heap::kTheHoleValueRootIndex); __ cmp(r4, r6); __ beq(&slow); Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/lithium-codegen-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/lithium-codegen-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/lithium-codegen-ppc.cc @@ -898,7 +898,7 @@ void LCodeGen::DoModI(LModI* instr) { if (divisor < 0) divisor = -divisor; Label positive_dividend; - __ cmpi(dividend, Operand::Zero()); + __ cmpwi(dividend, Operand::Zero()); __ bge(&positive_dividend); __ neg(result, dividend); __ mov(scratch, Operand(divisor - 1)); @@ -918,7 +918,7 @@ void LCodeGen::DoModI(LModI* instr) { // Check for x % 0. if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { - __ cmpi(divisor, Operand::Zero()); + __ cmpwi(divisor, Operand::Zero()); DeoptimizeIf(eq, instr->environment()); } @@ -929,7 +929,7 @@ void LCodeGen::DoModI(LModI* instr) { __ sub(result, dividend, scratch, LeaveOE, SetRC); if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { - __ cmpi(dividend, Operand::Zero()); + __ cmpwi(dividend, Operand::Zero()); __ bge(&done); DeoptimizeIf(eq, instr->environment(), cr0); } @@ -949,16 +949,16 @@ void LCodeGen::DoDivI(LDivI* instr) { // Check for x / 0. if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { - __ cmpi(right, Operand::Zero()); + __ cmpwi(right, Operand::Zero()); DeoptimizeIf(eq, instr->environment()); } // Check for (0 / -x) that will produce negative zero. if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { Label left_not_zero; - __ cmpi(left, Operand::Zero()); + __ cmpwi(left, Operand::Zero()); __ bne(&left_not_zero); - __ cmpi(right, Operand::Zero()); + __ cmpwi(right, Operand::Zero()); DeoptimizeIf(lt, instr->environment()); __ bind(&left_not_zero); } @@ -966,9 +966,9 @@ void LCodeGen::DoDivI(LDivI* instr) { // Check for (-kMinInt / -1). if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { Label left_not_min_int; - __ Cmpi(left, Operand(kMinInt), r0); + __ Cmpwi(left, Operand(kMinInt), r0); __ bne(&left_not_min_int); - __ cmpi(right, Operand(-1)); + __ cmpwi(right, Operand(-1)); DeoptimizeIf(eq, instr->environment()); __ bind(&left_not_min_int); } @@ -979,7 +979,7 @@ void LCodeGen::DoDivI(LDivI* instr) { // Deoptimize on non-zero remainder __ Mul(scratch, right, result); - __ cmp(left, scratch); + __ cmpw(left, scratch); DeoptimizeIf(ne, instr->environment()); } @@ -1126,7 +1126,7 @@ void LCodeGen::DoMulI(LMulI* instr) { if (bailout_on_minus_zero) { // If left is strictly negative and the constant is null, the // result is -0. Deoptimize if required, otherwise return 0. - __ cmpi(left, Operand::Zero()); + __ cmpwi(left, Operand::Zero()); DeoptimizeIf(lt, instr->environment()); } __ li(result, Operand::Zero()); @@ -1194,7 +1194,7 @@ void LCodeGen::DoMulI(LMulI* instr) { Label done; __ cmpi(result, Operand::Zero()); __ bne(&done); - __ cmpi(ToRegister(instr->temp()), Operand::Zero()); + __ cmpwi(ToRegister(instr->temp()), Operand::Zero()); DeoptimizeIf(lt, instr->environment()); __ bind(&done); } @@ -1314,8 +1314,8 @@ void LCodeGen::DoShiftI(LShiftI* instr) __ srwi(result, left, Operand(shift_count)); } else { if (instr->can_deopt()) { - __ TestSignBit32(left, r0); - DeoptimizeIf(ne, instr->environment(), cr0); + __ cmpwi(left, Operand::Zero()); + DeoptimizeIf(lt, instr->environment()); } __ Move(result, left); } @@ -1549,7 +1549,7 @@ void LCodeGen::DoMathMinMax(LMathMinMax* Register right_reg = EmitLoadRegister(right, ip); Register result_reg = ToRegister(instr->result()); Label return_left, done; - __ cmp(left_reg, right_reg); + __ cmpw(left_reg, right_reg); __ b(cond, &return_left); __ Move(result_reg, right_reg); __ b(&done); @@ -1690,7 +1690,7 @@ void LCodeGen::DoBranch(LBranch* instr) Representation r = instr->hydrogen()->value()->representation(); if (r.IsInteger32()) { Register reg = ToRegister(instr->value()); - __ cmpi(reg, Operand::Zero()); + __ cmpwi(reg, Operand::Zero()); EmitBranch(true_block, false_block, ne); } else if (r.IsDouble()) { DoubleRegister reg = ToDoubleRegister(instr->value()); @@ -1868,15 +1868,15 @@ void LCodeGen::DoCmpIDAndBranch(LCmpIDAn __ bunordered(chunk_->GetAssemblyLabel(false_block)); } else { if (right->IsConstantOperand()) { - __ Cmpi(ToRegister(left), + __ Cmpwi(ToRegister(left), Operand(ToInteger32(LConstantOperand::cast(right))), r0); } else if (left->IsConstantOperand()) { - __ Cmpi(ToRegister(right), + __ Cmpwi(ToRegister(right), Operand(ToInteger32(LConstantOperand::cast(left))), r0); // We transposed the operands. Reverse the condition. cond = ReverseCondition(cond); } else { - __ cmp(ToRegister(left), ToRegister(right)); + __ cmpw(ToRegister(left), ToRegister(right)); } } EmitBranch(true_block, false_block, cond); @@ -2781,7 +2781,7 @@ void LCodeGen::DoLoadKeyedFastElement(LL __ add(scratch, elements, r0); offset = FixedArray::OffsetOfElementAt(instr->additional_index()); } - __ LoadP(result, FieldMemOperand(store_base, offset)); + __ LoadP(result, FieldMemOperand(store_base, offset), r0); // Check for the hole value. if (instr->hydrogen()->RequiresHoleCheck()) { @@ -3000,7 +3000,7 @@ void LCodeGen::DoLoadKeyedSpecializedArr } if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { __ lis(r0, Operand(SIGN_EXT_IMM16(0x8000))); - __ cmpl(result, r0); + __ cmplw(result, r0); DeoptimizeIf(ge, instr->environment()); } break; @@ -3323,10 +3323,10 @@ void LCodeGen::DoDeferredMathAbsTaggedHe __ lwz(exponent, FieldMemOperand(input, HeapNumber::kExponentOffset)); // Check the sign of the argument. If the argument is positive, just // return it. - __ TestSignBit32(exponent, r0); + __ cmpwi(exponent, Operand::Zero()); // Move the input to the result if necessary. __ Move(result, input); - __ beq(&done, cr0); + __ bge(&done); // Input is negative. Reverse its sign. // Preserve the value of all registers. @@ -3451,8 +3451,8 @@ void LCodeGen::DoMathFloor(LUnaryMathOpe __ lwz(scratch, MemOperand(sp, 0)); #endif __ addi(sp, sp, Operand(8)); - __ TestSignBit32(scratch, r0); - DeoptimizeIf(ne, instr->environment(), cr0); + __ cmpwi(scratch, Operand::Zero()); + DeoptimizeIf(lt, instr->environment()); __ bind(&done); } } @@ -3540,8 +3540,8 @@ void LCodeGen::DoMathRound(LUnaryMathOpe __ lwz(scratch, MemOperand(sp, 0)); #endif __ addi(sp, sp, Operand(8)); - __ TestSignBit32(scratch, r0); - DeoptimizeIf(ne, instr->environment(), cr0); + __ cmpwi(scratch, Operand::Zero()); + DeoptimizeIf(lt, instr->environment()); } __ bind(&done); } @@ -3687,6 +3687,7 @@ void LCodeGen::DoRandom(LRandom* instr) __ stw(r4, MemOperand(sp, 0)); __ stw(r3, MemOperand(sp, 4)); #endif + __ nop(); // LHS/RAW optimization __ lfd(d7, MemOperand(sp, 0)); // Move 0x4130000000000000 to VFP. @@ -3698,6 +3699,7 @@ void LCodeGen::DoRandom(LRandom* instr) __ stw(r4, MemOperand(sp, 0)); __ stw(r3, MemOperand(sp, 4)); #endif + __ nop(); // LHS/RAW optimization __ lfd(d8, MemOperand(sp, 0)); __ addi(sp, sp, Operand(8)); @@ -4688,8 +4690,8 @@ void LCodeGen::DoDeferredTaggedToI(LTagg #else __ lwz(scratch1, FieldMemOperand(scratch2, HeapNumber::kValueOffset)); #endif - __ TestSignBit32(scratch1, r0); - DeoptimizeIf(ne, instr->environment(), cr0); + __ cmpwi(scratch1, Operand::Zero()); + DeoptimizeIf(lt, instr->environment()); } } __ bind(&done); Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.cc @@ -58,7 +58,7 @@ MacroAssembler::MacroAssembler(Isolate* void MacroAssembler::Jump(Register target, Condition cond) { ASSERT(cond == al); mtctr(target); - bcr(); + bctr(); } @@ -73,7 +73,7 @@ void MacroAssembler::Jump(intptr_t targe mov(r0, Operand(target, rmode)); mtctr(r0); - bcr(); + bctr(); bind(&skip); // mov(pc, Operand(target, rmode), LeaveCC, cond); @@ -111,8 +111,8 @@ void MacroAssembler::Call(Register targe positions_recorder()->WriteRecordedPositions(); // branch via link register and set LK bit for return point - mtlr(target); - bclr(BA, SetLK); + mtctr(target); + bctrl(); ASSERT_EQ(CallSize(target, cond), SizeOfCodeGeneratedSince(&start)); } @@ -193,8 +193,8 @@ void MacroAssembler::Call(Address target // mov(ip, Operand(reinterpret_cast<intptr_t>(target), rmode)); - mtlr(ip); - bclr(BA, SetLK); + mtctr(ip); + bctrl(); #if V8_TARGET_ARCH_PPC64 ASSERT(kCallTargetAddressOffset == 7 * kInstrSize); @@ -1068,7 +1068,7 @@ void MacroAssembler::JumpToHandlerEntry( SmiUntag(ip, r5); add(r0, r4, ip); mtctr(r0); - bcr(); + bctr(); } @@ -2264,6 +2264,7 @@ void MacroAssembler::ConvertToInt32(Regi addi(sp, sp, Operand(-kDoubleSize)); stfd(double_scratch, MemOperand(sp, 0)); + nop(); // LHS/RAW optimization #if V8_TARGET_ARCH_PPC64 ld(dest, MemOperand(sp, 0)); #else @@ -2305,6 +2306,7 @@ void MacroAssembler::EmitVFPTruncate(VFP addi(sp, sp, Operand(-kDoubleSize)); stfd(double_scratch, MemOperand(sp, 0)); + nop(); // LHS/RAW optimization #if V8_TARGET_ARCH_PPC64 ld(result, MemOperand(sp, 0)); #else @@ -2439,6 +2441,7 @@ void MacroAssembler::EmitECMATruncate(Re // reserve a slot on the stack stfdu(double_scratch, MemOperand(sp, -8)); + nop(); // LHS/RAW optimization #if V8_TARGET_ARCH_PPC64 ld(result, MemOperand(sp, 0)); #else @@ -2462,6 +2465,7 @@ void MacroAssembler::EmitECMATruncate(Re // Load the double value and perform a manual truncation. stfd(double_input, MemOperand(sp)); + nop(); // LHS/RAW optimization #if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN lwz(input_low, MemOperand(sp)); lwz(input_high, MemOperand(sp, 4)); @@ -3843,6 +3847,7 @@ void MacroAssembler::ClampDoubleToUint8( // reserve a slot on the stack stfdu(temp_double_reg, MemOperand(sp, -8)); + nop(); // LHS/RAW optimization #if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN lwz(result_reg, MemOperand(sp)); #else @@ -3966,6 +3971,7 @@ void MacroAssembler::LoadDoubleLiteral(D LoadIntLiteral(scratch, litVal.ival[1]); stw(scratch, MemOperand(sp, 4)); #endif + nop(); // LHS/RAW optimization lfd(result, MemOperand(sp, 0)); addi(sp, sp, Operand(8)); // restore the stack ptr @@ -4003,6 +4009,31 @@ void MacroAssembler::Cmpli(Register src1 } } + +void MacroAssembler::Cmpwi(Register src1, const Operand& src2, + Register scratch, CRegister cr) { + intptr_t value = src2.immediate(); + if (is_int16(value)) { + cmpwi(src1, src2, cr); + } else { + mov(scratch, src2); + cmpw(src1, scratch, cr); + } +} + + +void MacroAssembler::Cmplwi(Register src1, const Operand& src2, + Register scratch, CRegister cr) { + intptr_t value = src2.immediate(); + if (is_uint16(value)) { + cmplwi(src1, src2, cr); + } else { + mov(scratch, src2); + cmplw(src1, scratch, cr); + } +} + + void MacroAssembler::And(Register ra, Register rs, const Operand& rb, RCBit rc) { if (rb.is_reg()) { Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.h =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.h +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/macro-assembler-ppc.h @@ -525,6 +525,10 @@ class MacroAssembler: public Assembler { CRegister cr = cr7); void Cmpli(Register src1, const Operand& src2, Register scratch, CRegister cr = cr7); + void Cmpwi(Register src1, const Operand& src2, Register scratch, + CRegister cr = cr7); + void Cmplwi(Register src1, const Operand& src2, Register scratch, + CRegister cr = cr7); void And(Register ra, Register rs, const Operand& rb, RCBit rc = LeaveRC); void Or(Register ra, Register rs, const Operand& rb, RCBit rc = LeaveRC); void Xor(Register ra, Register rs, const Operand& rb, RCBit rc = LeaveRC); Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/regexp-macro-assembler-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/regexp-macro-assembler-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/regexp-macro-assembler-ppc.cc @@ -198,7 +198,7 @@ void RegExpMacroAssemblerPPC::Backtrack( Pop(r3); __ add(r3, r3, code_pointer()); __ mtctr(r3); - __ bcr(); + __ bctr(); } @@ -927,7 +927,7 @@ Handle<HeapObject> RegExpMacroAssemblerP __ MultiPop(registers_to_retain); __ pop(r0); __ mtctr(r0); - __ bcr(); + __ bctr(); // Backtrack code (branch target for conditional backtracks). if (backtrack_label_.is_linked()) { @@ -1213,7 +1213,7 @@ int RegExpMacroAssemblerPPC::CheckStackG MaybeObject* result = Execution::HandleStackGuardInterrupt(isolate); if (*code_handle != re_code) { // Return address no longer valid - int delta = code_handle->address() - re_code->address(); + intptr_t delta = code_handle->address() - re_code->address(); // Overwrite the return address on the stack. *return_address += delta; } Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/simulator-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/simulator-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/simulator-ppc.cc @@ -1868,7 +1868,10 @@ bool Simulator::DecodeExt2_10bit(Instruc return found; } -void Simulator::DecodeExt2_9bit(Instruction* instr) { + +bool Simulator::DecodeExt2_9bit_part1(Instruction* instr) { + bool found = true; + int opcode = instr->Bits(9, 1) << 1; switch (opcode) { case TW: { @@ -1879,13 +1882,26 @@ void Simulator::DecodeExt2_9bit(Instruct case CMP: { int ra = instr->RAValue(); int rb = instr->RBValue(); - intptr_t ra_val = get_register(ra); - intptr_t rb_val = get_register(rb); int cr = instr->Bits(25, 23); int bf = 0; - if (ra_val < rb_val) { bf |= 0x80000000; } - if (ra_val > rb_val) { bf |= 0x40000000; } - if (ra_val == rb_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + int L = instr->Bit(21); + if (L) { +#endif + intptr_t ra_val = get_register(ra); + intptr_t rb_val = get_register(rb); + if (ra_val < rb_val) { bf |= 0x80000000; } + if (ra_val > rb_val) { bf |= 0x40000000; } + if (ra_val == rb_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + } else { + int32_t ra_val = get_register(ra); + int32_t rb_val = get_register(rb); + if (ra_val < rb_val) { bf |= 0x80000000; } + if (ra_val > rb_val) { bf |= 0x40000000; } + if (ra_val == rb_val) { bf |= 0x20000000; } + } +#endif int condition_mask = 0xF0000000 >> (cr*4); int condition = bf >> (cr*4); condition_reg_ = (condition_reg_ & ~condition_mask) | condition; @@ -1953,9 +1969,15 @@ void Simulator::DecodeExt2_9bit(Instruct int ra = instr->RAValue(); intptr_t ra_val = get_register(ra); intptr_t alu_out = 1 + ~ra_val; +#if V8_TARGET_ARCH_PPC64 + intptr_t one = 1; // work-around gcc + intptr_t kOverflowVal = (one << 63); +#else + intptr_t kOverflowVal = kMinInt; +#endif set_register(rt, alu_out); if (instr->Bit(10)) { // OE bit set - if (ra_val == kMinInt) { + if (ra_val == kOverflowVal) { special_reg_xer_ |= 0xC0000000; // set SO,OV } else { special_reg_xer_ &= ~0x40000000; // clear OV @@ -1995,6 +2017,19 @@ void Simulator::DecodeExt2_9bit(Instruct break; } #endif + default: { + found = false; + break; + } + } + + return found; +} + + +void Simulator::DecodeExt2_9bit_part2(Instruction* instr) { + int opcode = instr->Bits(9, 1) << 1; + switch (opcode) { case CNTLZWX: { int rs = instr->RSValue(); int ra = instr->RAValue(); @@ -2070,13 +2105,26 @@ void Simulator::DecodeExt2_9bit(Instruct case CMPL: { int ra = instr->RAValue(); int rb = instr->RBValue(); - uintptr_t ra_val = get_register(ra); - uintptr_t rb_val = get_register(rb); int cr = instr->Bits(25, 23); int bf = 0; - if (ra_val < rb_val) { bf |= 0x80000000; } - if (ra_val > rb_val) { bf |= 0x40000000; } - if (ra_val == rb_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + int L = instr->Bit(21); + if (L) { +#endif + uintptr_t ra_val = get_register(ra); + uintptr_t rb_val = get_register(rb); + if (ra_val < rb_val) { bf |= 0x80000000; } + if (ra_val > rb_val) { bf |= 0x40000000; } + if (ra_val == rb_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + } else { + uint32_t ra_val = get_register(ra); + uint32_t rb_val = get_register(rb); + if (ra_val < rb_val) { bf |= 0x80000000; } + if (ra_val > rb_val) { bf |= 0x40000000; } + if (ra_val == rb_val) { bf |= 0x20000000; } + } +#endif int condition_mask = 0xF0000000 >> (cr*4); int condition = bf >> (cr*4); condition_reg_ = (condition_reg_ & ~condition_mask) | condition; @@ -2392,7 +2440,9 @@ void Simulator::DecodeExt2(Instruction* if (DecodeExt2_10bit(instr)) return; // Now look at the lesser encodings - DecodeExt2_9bit(instr); + if (DecodeExt2_9bit_part1(instr)) + return; + DecodeExt2_9bit_part2(instr); } void Simulator::DecodeExt4(Instruction* instr) { @@ -2805,13 +2855,25 @@ void Simulator::InstructionDecode(Instru } case CMPLI: { int ra = instr->RAValue(); - uintptr_t ra_val = get_register(ra); uint32_t im_val = instr->Bits(15, 0); int cr = instr->Bits(25, 23); int bf = 0; - if (ra_val < im_val) { bf |= 0x80000000; } - if (ra_val > im_val) { bf |= 0x40000000; } - if (ra_val == im_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + int L = instr->Bit(21); + if (L) { +#endif + uintptr_t ra_val = get_register(ra); + if (ra_val < im_val) { bf |= 0x80000000; } + if (ra_val > im_val) { bf |= 0x40000000; } + if (ra_val == im_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + } else { + uint32_t ra_val = get_register(ra); + if (ra_val < im_val) { bf |= 0x80000000; } + if (ra_val > im_val) { bf |= 0x40000000; } + if (ra_val == im_val) { bf |= 0x20000000; } + } +#endif int condition_mask = 0xF0000000 >> (cr*4); int condition = bf >> (cr*4); condition_reg_ = (condition_reg_ & ~condition_mask) | condition; @@ -2819,14 +2881,26 @@ void Simulator::InstructionDecode(Instru } case CMPI: { int ra = instr->RAValue(); - intptr_t ra_val = get_register(ra); int32_t im_val = instr->Bits(15, 0); im_val = SIGN_EXT_IMM16(im_val); int cr = instr->Bits(25, 23); int bf = 0; - if (ra_val < im_val) { bf |= 0x80000000; } - if (ra_val > im_val) { bf |= 0x40000000; } - if (ra_val == im_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + int L = instr->Bit(21); + if (L) { +#endif + intptr_t ra_val = get_register(ra); + if (ra_val < im_val) { bf |= 0x80000000; } + if (ra_val > im_val) { bf |= 0x40000000; } + if (ra_val == im_val) { bf |= 0x20000000; } +#if V8_TARGET_ARCH_PPC64 + } else { + int32_t ra_val = get_register(ra); + if (ra_val < im_val) { bf |= 0x80000000; } + if (ra_val > im_val) { bf |= 0x40000000; } + if (ra_val == im_val) { bf |= 0x20000000; } + } +#endif int condition_mask = 0xF0000000 >> (cr*4); int condition = bf >> (cr*4); condition_reg_ = (condition_reg_ & ~condition_mask) | condition; Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/simulator-ppc.h =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/simulator-ppc.h +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/simulator-ppc.h @@ -268,7 +268,8 @@ class Simulator { void DecodeBranchConditional(Instruction* instr); void DecodeExt1(Instruction* instr); bool DecodeExt2_10bit(Instruction* instr); - void DecodeExt2_9bit(Instruction* instr); + bool DecodeExt2_9bit_part1(Instruction* instr); + void DecodeExt2_9bit_part2(Instruction* instr); void DecodeExt2(Instruction* instr); void DecodeExt4(Instruction* instr); #if V8_TARGET_ARCH_PPC64 Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/stub-cache-ppc.cc =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/ppc/stub-cache-ppc.cc +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/ppc/stub-cache-ppc.cc @@ -121,7 +121,7 @@ static void ProbeTable(Isolate* isolate, // Jump to the first instruction in the code stub. __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); __ mtctr(r0); - __ bcr(); + __ bctr(); // Miss: fall through. __ bind(&miss); Index: mongodb-src-r2.4.10/src/third_party/v8-3.14/src/third_party/valgrind/valgrind.h =================================================================== --- mongodb-src-r2.4.10.orig/src/third_party/v8-3.14/src/third_party/valgrind/valgrind.h +++ mongodb-src-r2.4.10/src/third_party/v8-3.14/src/third_party/valgrind/valgrind.h @@ -21,16 +21,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -52,13 +52,13 @@ the terms of the GNU General Public License, version 2. See the COPYING file in the source distribution for details. - ---------------------------------------------------------------- + ---------------------------------------------------------------- */ /* This file is for inclusion into client (your!) code. - You can use these macros to manipulate and query Valgrind's + You can use these macros to manipulate and query Valgrind's execution inside your own programs. The resulting executables will still run without Valgrind, just a @@ -194,8 +194,8 @@ this is executed not under Valgrind. Args are passed in a memory block, and so there's no intrinsic limit to the number that could be passed, but it's currently five. - - The macro args are: + + The macro args are: _zzq_rlval result lvalue _zzq_default default value (result returned when running on real CPU) _zzq_request request code @@ -222,7 +222,7 @@ || (defined(PLAT_x86_win32) && defined(__GNUC__)) typedef - struct { + struct { unsigned int nraddr; /* where's the code? */ } OrigFn; @@ -277,7 +277,7 @@ typedef #if defined(PLAT_x86_win32) && !defined(__GNUC__) typedef - struct { + struct { unsigned int nraddr; /* where's the code? */ } OrigFn; @@ -343,7 +343,7 @@ valgrind_do_client_request_expr(uintptr_ #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) typedef - struct { + struct { uint64_t nraddr; /* where's the code? */ } OrigFn; @@ -398,7 +398,7 @@ typedef #if defined(PLAT_ppc32_linux) typedef - struct { + struct { unsigned int nraddr; /* where's the code? */ } OrigFn; @@ -459,7 +459,7 @@ typedef #if defined(PLAT_ppc64_linux) typedef - struct { + struct { uint64_t nraddr; /* where's the code? */ uint64_t r2; /* what tocptr do we need? */ } @@ -526,7 +526,7 @@ typedef #if defined(PLAT_arm_linux) typedef - struct { + struct { unsigned int nraddr; /* where's the code? */ } OrigFn; @@ -1709,7 +1709,7 @@ typedef "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ "r11", "r12", "r13" -/* These CALL_FN_ macros assume that on ppc32-linux, +/* These CALL_FN_ macros assume that on ppc32-linux, sizeof(unsigned long) == 4. */ #define CALL_FN_W_v(lval, orig) \ @@ -3581,7 +3581,7 @@ typedef #define VG_IS_TOOL_USERREQ(a, b, v) \ (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000)) -/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! +/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! This enum comprises an ABI exported by Valgrind to programs which use client requests. DO NOT CHANGE THE ORDER OF THESE ENTRIES, NOR DELETE ANY -- add new ones at the end. */ @@ -3710,7 +3710,7 @@ VALGRIND_PRINTF(const char *format, ...) _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, VG_USERREQ__PRINTF_VALIST_BY_REF, (unsigned long)format, - (unsigned long)&vargs, + (unsigned long)&vargs, 0, 0, 0); #endif va_end(vargs); @@ -3748,7 +3748,7 @@ VALGRIND_PRINTF_BACKTRACE(const char *fo _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF, (unsigned long)format, - (unsigned long)&vargs, + (unsigned long)&vargs, 0, 0, 0); #endif va_end(vargs); @@ -3759,7 +3759,7 @@ VALGRIND_PRINTF_BACKTRACE(const char *fo /* These requests allow control to move from the simulated CPU to the real CPU, calling an arbitary function. - + Note that the current ThreadId is inserted as the first argument. So this call: @@ -3845,7 +3845,7 @@ VALGRIND_PRINTF_BACKTRACE(const char *fo - It marks the block as being addressable and undefined (if 'is_zeroed' is not set), or addressable and defined (if 'is_zeroed' is set). This controls how accesses to the block by the program are handled. - + 'addr' is the start of the usable block (ie. after any redzone), 'sizeB' is its size. 'rzB' is the redzone size if the allocator can apply redzones -- these are blocks of padding at the start and end of @@ -3853,7 +3853,7 @@ VALGRIND_PRINTF_BACKTRACE(const char *fo Valgrind will spot block overruns. `is_zeroed' indicates if the memory is zeroed (or filled with another predictable value), as is the case for calloc(). - + VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a heap block -- that will be used by the client program -- is allocated. It's best to put it at the outermost level of the allocator if possible;