2011-10-03 11:44:39 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
2008-08-22 13:33:59 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "v8.h"
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "disasm.h"
|
|
|
|
#include "disassembler.h"
|
|
|
|
#include "macro-assembler.h"
|
|
|
|
#include "serialize.h"
|
|
|
|
#include "cctest.h"
|
|
|
|
|
|
|
|
using namespace v8::internal;
|
|
|
|
|
|
|
|
static v8::Persistent<v8::Context> env;
|
|
|
|
|
|
|
|
static void InitializeVM() {
|
|
|
|
if (env.IsEmpty()) {
|
|
|
|
env = v8::Context::New();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define __ assm.
|
|
|
|
|
|
|
|
|
|
|
|
static void DummyStaticFunction(Object* result) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(DisasmIa320) {
|
|
|
|
InitializeVM();
|
|
|
|
v8::HandleScope scope;
|
2010-01-11 15:19:53 +00:00
|
|
|
v8::internal::byte buffer[2048];
|
2011-03-31 16:17:37 +00:00
|
|
|
Assembler assm(Isolate::Current(), buffer, sizeof buffer);
|
2008-08-22 13:33:59 +00:00
|
|
|
DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging)
|
|
|
|
|
|
|
|
// Short immediate instructions
|
|
|
|
__ adc(eax, 12345678);
|
2011-10-03 11:44:39 +00:00
|
|
|
__ add(eax, Immediate(12345678));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ or_(eax, 12345678);
|
2011-10-03 11:44:39 +00:00
|
|
|
__ sub(eax, Immediate(12345678));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ xor_(eax, 12345678);
|
|
|
|
__ and_(eax, 12345678);
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ cmp(eax, foo);
|
|
|
|
|
|
|
|
// ---- This one caused crash
|
|
|
|
__ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4]
|
|
|
|
|
|
|
|
// ---- All instructions that I can think of
|
2011-10-03 11:44:39 +00:00
|
|
|
__ add(edx, ebx);
|
2013-01-04 10:56:24 +00:00
|
|
|
__ add(edx, Operand(12, RelocInfo::NONE32));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ add(edx, Operand(ebx, 0));
|
|
|
|
__ add(edx, Operand(ebx, 16));
|
|
|
|
__ add(edx, Operand(ebx, 1999));
|
|
|
|
__ add(edx, Operand(esp, 0));
|
|
|
|
__ add(edx, Operand(esp, 16));
|
|
|
|
__ add(edx, Operand(esp, 1999));
|
|
|
|
__ nop();
|
|
|
|
__ add(edi, Operand(ebp, ecx, times_4, 0));
|
|
|
|
__ add(edi, Operand(ebp, ecx, times_4, 12));
|
|
|
|
__ add(Operand(ebp, ecx, times_4, 12), Immediate(12));
|
|
|
|
|
|
|
|
__ nop();
|
2011-10-03 11:44:39 +00:00
|
|
|
__ add(ebx, Immediate(12));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ nop();
|
|
|
|
__ adc(ecx, 12);
|
|
|
|
__ adc(ecx, 1000);
|
|
|
|
__ nop();
|
|
|
|
__ and_(edx, 3);
|
|
|
|
__ and_(edx, Operand(esp, 4));
|
|
|
|
__ cmp(edx, 3);
|
|
|
|
__ cmp(edx, Operand(esp, 4));
|
|
|
|
__ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000));
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ cmp(ebx, foo2);
|
2010-01-21 12:10:56 +00:00
|
|
|
__ cmpb(ebx, Operand(ebp, ecx, times_2, 0));
|
|
|
|
__ cmpb(Operand(ebp, ecx, times_2, 0), ebx);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ or_(edx, 3);
|
|
|
|
__ xor_(edx, 3);
|
|
|
|
__ nop();
|
|
|
|
{
|
2011-03-31 16:17:37 +00:00
|
|
|
CHECK(CpuFeatures::IsSupported(CPUID));
|
2009-11-13 12:32:57 +00:00
|
|
|
CpuFeatures::Scope fscope(CPUID);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ cpuid();
|
|
|
|
}
|
|
|
|
{
|
2011-03-31 16:17:37 +00:00
|
|
|
CHECK(CpuFeatures::IsSupported(RDTSC));
|
2009-11-13 12:32:57 +00:00
|
|
|
CpuFeatures::Scope fscope(RDTSC);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ rdtsc();
|
|
|
|
}
|
2011-10-03 11:44:39 +00:00
|
|
|
__ movsx_b(edx, ecx);
|
|
|
|
__ movsx_w(edx, ecx);
|
|
|
|
__ movzx_b(edx, ecx);
|
|
|
|
__ movzx_w(edx, ecx);
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
__ nop();
|
2011-10-03 11:44:39 +00:00
|
|
|
__ imul(edx, ecx);
|
|
|
|
__ shld(edx, ecx);
|
|
|
|
__ shrd(edx, ecx);
|
|
|
|
__ bts(edx, ecx);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ bts(Operand(ebx, ecx, times_4, 0), ecx);
|
|
|
|
__ nop();
|
|
|
|
__ pushad();
|
|
|
|
__ popad();
|
|
|
|
__ pushfd();
|
|
|
|
__ popfd();
|
|
|
|
__ push(Immediate(12));
|
|
|
|
__ push(Immediate(23456));
|
|
|
|
__ push(ecx);
|
|
|
|
__ push(esi);
|
|
|
|
__ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
|
|
|
|
__ push(Operand(ebx, ecx, times_4, 0));
|
|
|
|
__ push(Operand(ebx, ecx, times_4, 0));
|
|
|
|
__ push(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ pop(edx);
|
|
|
|
__ pop(eax);
|
|
|
|
__ pop(Operand(ebx, ecx, times_4, 0));
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ add(edx, Operand(esp, 16));
|
2011-10-03 11:44:39 +00:00
|
|
|
__ add(edx, ecx);
|
|
|
|
__ mov_b(edx, ecx);
|
|
|
|
__ mov_b(ecx, 6);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ mov_b(Operand(ebx, ecx, times_4, 10000), 6);
|
|
|
|
__ mov_b(Operand(esp, 16), edx);
|
|
|
|
__ mov_w(edx, Operand(esp, 16));
|
|
|
|
__ mov_w(Operand(esp, 16), edx);
|
|
|
|
__ nop();
|
|
|
|
__ movsx_w(edx, Operand(esp, 12));
|
|
|
|
__ movsx_b(edx, Operand(esp, 12));
|
|
|
|
__ movzx_w(edx, Operand(esp, 12));
|
|
|
|
__ movzx_b(edx, Operand(esp, 12));
|
|
|
|
__ nop();
|
|
|
|
__ mov(edx, 1234567);
|
|
|
|
__ mov(edx, Operand(esp, 12));
|
|
|
|
__ mov(Operand(ebx, ecx, times_4, 10000), Immediate(12345));
|
|
|
|
__ mov(Operand(ebx, ecx, times_4, 10000), edx);
|
|
|
|
__ nop();
|
|
|
|
__ dec_b(edx);
|
2010-09-23 19:01:56 +00:00
|
|
|
__ dec_b(Operand(eax, 10));
|
|
|
|
__ dec_b(Operand(ebx, ecx, times_4, 10000));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ dec(edx);
|
|
|
|
__ cdq();
|
|
|
|
|
|
|
|
__ nop();
|
|
|
|
__ idiv(edx);
|
|
|
|
__ mul(edx);
|
|
|
|
__ neg(edx);
|
|
|
|
__ not_(edx);
|
|
|
|
__ test(Operand(ebx, ecx, times_4, 10000), Immediate(123456));
|
|
|
|
|
|
|
|
__ imul(edx, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ imul(edx, ecx, 12);
|
|
|
|
__ imul(edx, ecx, 1000);
|
|
|
|
|
|
|
|
__ inc(edx);
|
|
|
|
__ inc(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ push(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ pop(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ call(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ jmp(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
|
|
|
|
__ lea(edx, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ or_(edx, 12345);
|
|
|
|
__ or_(edx, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ rcl(edx, 1);
|
|
|
|
__ rcl(edx, 7);
|
2010-08-16 11:18:42 +00:00
|
|
|
__ rcr(edx, 1);
|
|
|
|
__ rcr(edx, 7);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ sar(edx, 1);
|
|
|
|
__ sar(edx, 6);
|
2009-11-17 08:35:43 +00:00
|
|
|
__ sar_cl(edx);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ sbb(edx, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ shld(edx, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ shl(edx, 1);
|
|
|
|
__ shl(edx, 6);
|
2009-11-17 08:35:43 +00:00
|
|
|
__ shl_cl(edx);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ shrd(edx, Operand(ebx, ecx, times_4, 10000));
|
2009-11-17 10:24:27 +00:00
|
|
|
__ shr(edx, 1);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ shr(edx, 7);
|
2009-11-17 08:35:43 +00:00
|
|
|
__ shr_cl(edx);
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Immediates
|
|
|
|
|
|
|
|
__ adc(edx, 12345);
|
|
|
|
|
2011-10-03 11:44:39 +00:00
|
|
|
__ add(ebx, Immediate(12));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ add(Operand(edx, ecx, times_4, 10000), Immediate(12));
|
|
|
|
|
|
|
|
__ and_(ebx, 12345);
|
|
|
|
|
|
|
|
__ cmp(ebx, 12345);
|
2011-10-03 11:44:39 +00:00
|
|
|
__ cmp(ebx, Immediate(12));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12));
|
2011-10-03 11:44:39 +00:00
|
|
|
__ cmpb(eax, 100);
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
__ or_(ebx, 12345);
|
|
|
|
|
2011-10-03 11:44:39 +00:00
|
|
|
__ sub(ebx, Immediate(12));
|
2008-08-22 13:33:59 +00:00
|
|
|
__ sub(Operand(edx, ecx, times_4, 10000), Immediate(12));
|
|
|
|
|
|
|
|
__ xor_(ebx, 12345);
|
|
|
|
|
|
|
|
__ imul(edx, ecx, 12);
|
|
|
|
__ imul(edx, ecx, 1000);
|
|
|
|
|
2010-03-02 12:42:15 +00:00
|
|
|
__ cld();
|
2010-01-11 15:19:53 +00:00
|
|
|
__ rep_movs();
|
2010-03-02 12:42:15 +00:00
|
|
|
__ rep_stos();
|
2010-05-17 14:14:34 +00:00
|
|
|
__ stos();
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
__ sub(edx, Operand(ebx, ecx, times_4, 10000));
|
2011-10-03 11:44:39 +00:00
|
|
|
__ sub(edx, ebx);
|
2008-08-22 13:33:59 +00:00
|
|
|
|
|
|
|
__ test(edx, Immediate(12345));
|
|
|
|
__ test(edx, Operand(ebx, ecx, times_8, 10000));
|
2010-06-08 12:44:24 +00:00
|
|
|
__ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000));
|
|
|
|
__ test_b(edx, Operand(ecx, ebx, times_2, 1000));
|
|
|
|
__ test_b(Operand(eax, -20), 0x9A);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ xor_(edx, 12345);
|
|
|
|
__ xor_(edx, Operand(ebx, ecx, times_8, 10000));
|
|
|
|
__ bts(Operand(ebx, ecx, times_8, 10000), edx);
|
|
|
|
__ hlt();
|
|
|
|
__ int3();
|
|
|
|
__ ret(0);
|
|
|
|
__ ret(8);
|
|
|
|
|
|
|
|
// Calls
|
|
|
|
|
|
|
|
Label L1, L2;
|
|
|
|
__ bind(&L1);
|
|
|
|
__ nop();
|
|
|
|
__ call(&L1);
|
|
|
|
__ call(&L2);
|
|
|
|
__ nop();
|
|
|
|
__ bind(&L2);
|
|
|
|
__ call(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ nop();
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Code> ic(Isolate::Current()->builtins()->builtin(
|
2011-03-23 13:40:07 +00:00
|
|
|
Builtins::kLoadIC_Initialize));
|
2008-09-22 13:57:03 +00:00
|
|
|
__ call(ic, RelocInfo::CODE_TARGET);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ nop();
|
2008-09-22 13:57:03 +00:00
|
|
|
__ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ jmp(&L1);
|
|
|
|
__ jmp(Operand(ebx, ecx, times_4, 10000));
|
2010-06-18 10:52:59 +00:00
|
|
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
2008-08-22 13:33:59 +00:00
|
|
|
ExternalReference after_break_target =
|
2011-03-22 13:20:04 +00:00
|
|
|
ExternalReference(Debug_Address::AfterBreakTarget(),
|
|
|
|
assm.isolate());
|
2008-08-22 13:33:59 +00:00
|
|
|
__ jmp(Operand::StaticVariable(after_break_target));
|
2010-06-18 10:52:59 +00:00
|
|
|
#endif // ENABLE_DEBUGGER_SUPPORT
|
2008-09-22 13:57:03 +00:00
|
|
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ nop();
|
|
|
|
|
|
|
|
|
|
|
|
Label Ljcc;
|
|
|
|
__ nop();
|
|
|
|
// long jumps
|
|
|
|
__ j(overflow, &Ljcc);
|
|
|
|
__ j(no_overflow, &Ljcc);
|
|
|
|
__ j(below, &Ljcc);
|
|
|
|
__ j(above_equal, &Ljcc);
|
|
|
|
__ j(equal, &Ljcc);
|
|
|
|
__ j(not_equal, &Ljcc);
|
|
|
|
__ j(below_equal, &Ljcc);
|
|
|
|
__ j(above, &Ljcc);
|
|
|
|
__ j(sign, &Ljcc);
|
|
|
|
__ j(not_sign, &Ljcc);
|
|
|
|
__ j(parity_even, &Ljcc);
|
|
|
|
__ j(parity_odd, &Ljcc);
|
|
|
|
__ j(less, &Ljcc);
|
|
|
|
__ j(greater_equal, &Ljcc);
|
|
|
|
__ j(less_equal, &Ljcc);
|
|
|
|
__ j(greater, &Ljcc);
|
|
|
|
__ nop();
|
|
|
|
__ bind(&Ljcc);
|
|
|
|
// short jumps
|
|
|
|
__ j(overflow, &Ljcc);
|
|
|
|
__ j(no_overflow, &Ljcc);
|
|
|
|
__ j(below, &Ljcc);
|
|
|
|
__ j(above_equal, &Ljcc);
|
|
|
|
__ j(equal, &Ljcc);
|
|
|
|
__ j(not_equal, &Ljcc);
|
|
|
|
__ j(below_equal, &Ljcc);
|
|
|
|
__ j(above, &Ljcc);
|
|
|
|
__ j(sign, &Ljcc);
|
|
|
|
__ j(not_sign, &Ljcc);
|
|
|
|
__ j(parity_even, &Ljcc);
|
|
|
|
__ j(parity_odd, &Ljcc);
|
|
|
|
__ j(less, &Ljcc);
|
|
|
|
__ j(greater_equal, &Ljcc);
|
|
|
|
__ j(less_equal, &Ljcc);
|
|
|
|
__ j(greater, &Ljcc);
|
|
|
|
|
|
|
|
// 0xD9 instructions
|
|
|
|
__ nop();
|
|
|
|
|
2010-09-24 12:55:17 +00:00
|
|
|
__ fld(1);
|
2008-08-22 13:33:59 +00:00
|
|
|
__ fld1();
|
|
|
|
__ fldz();
|
2010-09-24 12:55:17 +00:00
|
|
|
__ fldpi();
|
2008-08-22 13:33:59 +00:00
|
|
|
__ fabs();
|
|
|
|
__ fchs();
|
|
|
|
__ fprem();
|
|
|
|
__ fprem1();
|
|
|
|
__ fincstp();
|
|
|
|
__ ftst();
|
|
|
|
__ fxch(3);
|
|
|
|
__ fld_s(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ fstp_s(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ ffree(3);
|
|
|
|
__ fld_d(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ fstp_d(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ nop();
|
|
|
|
|
|
|
|
__ fild_s(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ fistp_s(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ fild_d(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ fistp_d(Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ fnstsw_ax();
|
|
|
|
__ nop();
|
|
|
|
__ fadd(3);
|
|
|
|
__ fsub(3);
|
|
|
|
__ fmul(3);
|
|
|
|
__ fdiv(3);
|
|
|
|
|
|
|
|
__ faddp(3);
|
|
|
|
__ fsubp(3);
|
|
|
|
__ fmulp(3);
|
|
|
|
__ fdivp(3);
|
|
|
|
__ fcompp();
|
|
|
|
__ fwait();
|
|
|
|
__ nop();
|
|
|
|
{
|
2011-03-31 16:17:37 +00:00
|
|
|
if (CpuFeatures::IsSupported(SSE2)) {
|
2010-03-17 10:28:44 +00:00
|
|
|
CpuFeatures::Scope fscope(SSE2);
|
|
|
|
__ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ addsd(xmm1, xmm0);
|
|
|
|
__ mulsd(xmm1, xmm0);
|
|
|
|
__ subsd(xmm1, xmm0);
|
|
|
|
__ divsd(xmm1, xmm0);
|
|
|
|
__ movdbl(xmm1, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ movdbl(Operand(ebx, ecx, times_4, 10000), xmm1);
|
2010-06-16 12:32:34 +00:00
|
|
|
__ ucomisd(xmm0, xmm1);
|
2010-03-17 10:28:44 +00:00
|
|
|
|
|
|
|
// 128 bit move instructions.
|
|
|
|
__ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0);
|
|
|
|
__ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000));
|
|
|
|
__ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0);
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
}
|
2009-10-08 13:28:46 +00:00
|
|
|
|
|
|
|
// cmov.
|
|
|
|
{
|
2011-03-31 16:17:37 +00:00
|
|
|
if (CpuFeatures::IsSupported(CMOV)) {
|
2010-03-17 10:28:44 +00:00
|
|
|
CpuFeatures::Scope use_cmov(CMOV);
|
|
|
|
__ cmov(overflow, eax, Operand(eax, 0));
|
|
|
|
__ cmov(no_overflow, eax, Operand(eax, 1));
|
|
|
|
__ cmov(below, eax, Operand(eax, 2));
|
|
|
|
__ cmov(above_equal, eax, Operand(eax, 3));
|
|
|
|
__ cmov(equal, eax, Operand(ebx, 0));
|
|
|
|
__ cmov(not_equal, eax, Operand(ebx, 1));
|
|
|
|
__ cmov(below_equal, eax, Operand(ebx, 2));
|
|
|
|
__ cmov(above, eax, Operand(ebx, 3));
|
|
|
|
__ cmov(sign, eax, Operand(ecx, 0));
|
|
|
|
__ cmov(not_sign, eax, Operand(ecx, 1));
|
|
|
|
__ cmov(parity_even, eax, Operand(ecx, 2));
|
|
|
|
__ cmov(parity_odd, eax, Operand(ecx, 3));
|
|
|
|
__ cmov(less, eax, Operand(edx, 0));
|
|
|
|
__ cmov(greater_equal, eax, Operand(edx, 1));
|
|
|
|
__ cmov(less_equal, eax, Operand(edx, 2));
|
|
|
|
__ cmov(greater, eax, Operand(edx, 3));
|
|
|
|
}
|
2009-10-08 13:28:46 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:48:49 +00:00
|
|
|
// andpd, cmpltsd, movaps, psllq, psrlq, por.
|
2010-09-21 12:54:12 +00:00
|
|
|
{
|
2011-03-31 16:17:37 +00:00
|
|
|
if (CpuFeatures::IsSupported(SSE2)) {
|
2010-09-21 12:54:12 +00:00
|
|
|
CpuFeatures::Scope fscope(SSE2);
|
|
|
|
__ andpd(xmm0, xmm1);
|
|
|
|
__ andpd(xmm1, xmm2);
|
|
|
|
|
|
|
|
__ cmpltsd(xmm0, xmm1);
|
|
|
|
__ cmpltsd(xmm1, xmm2);
|
|
|
|
|
|
|
|
__ movaps(xmm0, xmm1);
|
|
|
|
__ movaps(xmm1, xmm2);
|
|
|
|
|
|
|
|
__ psllq(xmm0, 17);
|
|
|
|
__ psllq(xmm1, 42);
|
2011-01-11 13:48:49 +00:00
|
|
|
|
|
|
|
__ psllq(xmm0, xmm1);
|
|
|
|
__ psllq(xmm1, xmm2);
|
|
|
|
|
|
|
|
__ psrlq(xmm0, 17);
|
|
|
|
__ psrlq(xmm1, 42);
|
|
|
|
|
|
|
|
__ psrlq(xmm0, xmm1);
|
|
|
|
__ psrlq(xmm1, xmm2);
|
|
|
|
|
|
|
|
__ por(xmm0, xmm1);
|
|
|
|
__ por(xmm1, xmm2);
|
2010-09-21 12:54:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-09 12:39:15 +00:00
|
|
|
{
|
2012-12-18 16:25:45 +00:00
|
|
|
if (CpuFeatures::IsSupported(SSE2) &&
|
|
|
|
CpuFeatures::IsSupported(SSE4_1)) {
|
2011-02-09 12:39:15 +00:00
|
|
|
CpuFeatures::Scope scope(SSE4_1);
|
2011-10-03 11:44:39 +00:00
|
|
|
__ pextrd(eax, xmm0, 1);
|
|
|
|
__ pinsrd(xmm1, eax, 0);
|
2011-02-09 12:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-02 10:01:50 +00:00
|
|
|
// Nop instructions
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
__ Nop(i);
|
|
|
|
}
|
|
|
|
|
2008-08-22 13:33:59 +00:00
|
|
|
__ ret(0);
|
|
|
|
|
|
|
|
CodeDesc desc;
|
|
|
|
assm.GetCode(&desc);
|
2011-03-18 20:35:07 +00:00
|
|
|
Object* code = HEAP->CreateCode(
|
2010-10-25 15:22:03 +00:00
|
|
|
desc,
|
|
|
|
Code::ComputeFlags(Code::STUB),
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Object>(HEAP->undefined_value()))->ToObjectChecked();
|
2008-08-22 13:33:59 +00:00
|
|
|
CHECK(code->IsCode());
|
2011-01-03 09:32:42 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
2008-08-22 13:33:59 +00:00
|
|
|
Code::cast(code)->Print();
|
|
|
|
byte* begin = Code::cast(code)->instruction_start();
|
|
|
|
byte* end = begin + Code::cast(code)->instruction_size();
|
|
|
|
disasm::Disassembler::Disassemble(stdout, begin, end);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef __
|