39 using namespace v8::internal;
43 typedef int (*
F1)(
int x);
44 typedef int (*
F2)(
int x,
int y);
55 Assembler assm(isolate, buffer,
sizeof buffer);
67 CHECK(code->IsCode());
73 ::printf(
"f() = %d\n", res);
84 Assembler assm(isolate, buffer,
sizeof buffer);
93 __ sub(
edx, Immediate(1));
106 CHECK(code->IsCode());
112 ::printf(
"f() = %d\n", res);
123 Assembler assm(isolate, buffer,
sizeof buffer);
132 __ sub(
edx, Immediate(1));
149 CHECK(code->IsCode());
155 ::printf(
"f() = %d\n", res);
160 typedef int (*
F3)(
float x);
170 Assembler assm(isolate, buffer,
sizeof buffer);
173 { CpuFeatureScope fscope(&assm,
SSE2);
189 F3 f = FUNCTION_CAST<F3>(code->
entry());
190 int res = f(static_cast<float>(-3.1415));
191 ::printf(
"f() = %d\n", res);
196 typedef int (*
F4)(
double x);
206 Assembler assm(isolate, buffer,
sizeof buffer);
209 CpuFeatureScope fscope(&assm,
SSE2);
224 F4 f = FUNCTION_CAST<F4>(code->
entry());
225 int res = f(2.718281828);
226 ::printf(
"f() = %d\n", res);
238 Assembler assm(isolate, buffer,
sizeof buffer);
240 __ mov(
eax,
Operand(reinterpret_cast<intptr_t>(&
baz), RelocInfo::NONE32));
249 F0 f = FUNCTION_CAST<F0>(code->
entry());
255 typedef double (*
F5)(
double x,
double y);
264 Assembler assm(isolate, buffer,
sizeof buffer);
266 CpuFeatureScope fscope(&assm,
SSE2);
274 __ sub(
esp, Immediate(8));
277 __ add(
esp, Immediate(8));
294 F5 f = FUNCTION_CAST<F5>(code->
entry());
295 double res = f(2.2, 1.1);
296 ::printf(
"f() = %f\n", res);
297 CHECK(2.29 < res && res < 2.31);
301 typedef double (*
F6)(
int x);
310 Assembler assm(isolate, buffer,
sizeof buffer);
311 CpuFeatureScope fscope(&assm,
SSE2);
315 __ sub(
esp, Immediate(8));
318 __ add(
esp, Immediate(8));
326 CHECK(code->IsCode());
333 ::printf(
"f() = %f\n", res);
334 CHECK(11.99 < res && res < 12.001);
338 typedef int (*
F7)(
double x,
double y);
346 enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 };
347 Label equal_l, less_l, greater_l, nan_l;
356 __ mov(
eax, kUndefined);
364 __ mov(
eax, kGreater);
382 CHECK(code->IsCode());
415 Assembler assm(isolate, buffer,
sizeof(buffer));
427 for (
int i = 0; i < 16; i++) {
468 CHECK(code->IsCode());
470 F0 f = FUNCTION_CAST<F0>(code->
entry());
477 #define ELEMENT_COUNT 4
483 CHECK(args[0]->IsArray());
488 Assembler assm(isolate, buffer,
sizeof buffer);
491 CpuFeatureScope fscope(&assm,
SSE2);
497 for (
int i = 0; i < ELEMENT_COUNT; ++i) {
498 __ push(Immediate(vec->
Get(i)->Int32Value()));
508 __ add(
esp, Immediate(ELEMENT_COUNT *
sizeof(
int32_t)));
521 CHECK(code->IsCode());
529 TEST(StackAlignmentForSSE2) {
539 global_template->
Set(v8_str(
"do_sse2"),
544 "function foo(vec) {"
545 " return do_sse2(vec);"
552 int32_t vec[ELEMENT_COUNT] = { -1, 1, 1, 1 };
554 for (
int i = 0; i < ELEMENT_COUNT; i++) {
555 v8_vec->
Set(i, v8_num(vec[i]));
578 { CpuFeatureScope fscope2(&assm,
SSE2);
579 CpuFeatureScope fscope41(&assm,
SSE4_1);
591 CHECK(code->IsCode());
604 typedef int (*
F8)(
float x,
float y);
614 CpuFeatureScope fscope(&assm,
SSE2);
634 CHECK(code->IsCode());
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
#define CHECK_EQ(expected, value)
Local< Value > Call(Handle< Value > recv, int argc, Handle< Value > argv[])
Local< Value > Get(Handle< Value > key)
V8_INLINE ReturnValue< T > GetReturnValue() const
static bool IsSupported(CpuFeature f)
#define ASSERT(condition)
static Local< Integer > New(Isolate *isolate, int32_t value)
int(* F8)(float x, float y)
void Set(Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
static Code * cast(Object *obj)
static Local< ObjectTemplate > New()
byte * instruction_start()
void GetCode(CodeDesc *desc)
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >(), int length=0)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
double uint64_to_double(uint64_t d64)
#define V8_2PART_UINT64_C(a, b)
static Local< Array > New(Isolate *isolate, int length=0)
static V8_INLINE Local< T > Cast(Local< S > that)
int(* F7)(double x, double y)
MUST_USE_RESULT MaybeObject * CreateCode(const CodeDesc &desc, Code::Flags flags, Handle< Object > self_reference, bool immovable=false, bool crankshafted=false, int prologue_offset=Code::kPrologueOffsetNotSet)
static double nan_value()
static void InitializeVM()
double(* F5)(double x, double y)
static Flags ComputeFlags(Kind kind, InlineCacheState ic_state=UNINITIALIZED, ExtraICState extra_ic_state=kNoExtraICState, StubType type=NORMAL, InlineCacheHolderFlag holder=OWN_MAP)
static int ActivationFrameAlignment()
#define RUNTIME_ENTRY(name, nargs, ressize)
static void Dump(FILE *f, byte *begin, byte *end)
bool Set(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
static v8::Isolate * isolate()