Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: src/arm/simulator-arm.cc

Issue 11418149: Faster implementation of Math.exp() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Win build Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 dbg.Debug(); 3294 dbg.Debug();
3295 } else { 3295 } else {
3296 InstructionDecode(instr); 3296 InstructionDecode(instr);
3297 } 3297 }
3298 program_counter = get_pc(); 3298 program_counter = get_pc();
3299 } 3299 }
3300 } 3300 }
3301 } 3301 }
3302 3302
3303 3303
3304 int32_t Simulator::Call(byte* entry, int argument_count, ...) { 3304 void Simulator::CallInternal(byte* entry) {
3305 va_list parameters;
3306 va_start(parameters, argument_count);
3307 // Set up arguments
3308
3309 // First four arguments passed in registers.
3310 ASSERT(argument_count >= 4);
3311 set_register(r0, va_arg(parameters, int32_t));
3312 set_register(r1, va_arg(parameters, int32_t));
3313 set_register(r2, va_arg(parameters, int32_t));
3314 set_register(r3, va_arg(parameters, int32_t));
3315
3316 // Remaining arguments passed on stack.
3317 int original_stack = get_register(sp);
3318 // Compute position of stack on entry to generated code.
3319 int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t));
3320 if (OS::ActivationFrameAlignment() != 0) {
3321 entry_stack &= -OS::ActivationFrameAlignment();
3322 }
3323 // Store remaining arguments on stack, from low to high memory.
3324 intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
3325 for (int i = 4; i < argument_count; i++) {
3326 stack_argument[i - 4] = va_arg(parameters, int32_t);
3327 }
3328 va_end(parameters);
3329 set_register(sp, entry_stack);
3330
3331 // Prepare to execute the code at entry 3305 // Prepare to execute the code at entry
3332 set_register(pc, reinterpret_cast<int32_t>(entry)); 3306 set_register(pc, reinterpret_cast<int32_t>(entry));
3333 // Put down marker for end of simulation. The simulator will stop simulation 3307 // Put down marker for end of simulation. The simulator will stop simulation
3334 // when the PC reaches this value. By saving the "end simulation" value into 3308 // when the PC reaches this value. By saving the "end simulation" value into
3335 // the LR the simulation stops when returning to this call point. 3309 // the LR the simulation stops when returning to this call point.
3336 set_register(lr, end_sim_pc); 3310 set_register(lr, end_sim_pc);
3337 3311
3338 // Remember the values of callee-saved registers. 3312 // Remember the values of callee-saved registers.
3339 // The code below assumes that r9 is not used as sb (static base) in 3313 // The code below assumes that r9 is not used as sb (static base) in
3340 // simulator code and therefore is regarded as a callee-saved register. 3314 // simulator code and therefore is regarded as a callee-saved register.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 3348
3375 // Restore callee-saved registers with the original value. 3349 // Restore callee-saved registers with the original value.
3376 set_register(r4, r4_val); 3350 set_register(r4, r4_val);
3377 set_register(r5, r5_val); 3351 set_register(r5, r5_val);
3378 set_register(r6, r6_val); 3352 set_register(r6, r6_val);
3379 set_register(r7, r7_val); 3353 set_register(r7, r7_val);
3380 set_register(r8, r8_val); 3354 set_register(r8, r8_val);
3381 set_register(r9, r9_val); 3355 set_register(r9, r9_val);
3382 set_register(r10, r10_val); 3356 set_register(r10, r10_val);
3383 set_register(r11, r11_val); 3357 set_register(r11, r11_val);
3358 }
3359
3360
3361 int32_t Simulator::Call(byte* entry, int argument_count, ...) {
3362 va_list parameters;
3363 va_start(parameters, argument_count);
3364 // Set up arguments
3365
3366 // First four arguments passed in registers.
3367 ASSERT(argument_count >= 4);
3368 set_register(r0, va_arg(parameters, int32_t));
3369 set_register(r1, va_arg(parameters, int32_t));
3370 set_register(r2, va_arg(parameters, int32_t));
3371 set_register(r3, va_arg(parameters, int32_t));
3372
3373 // Remaining arguments passed on stack.
3374 int original_stack = get_register(sp);
3375 // Compute position of stack on entry to generated code.
3376 int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t));
3377 if (OS::ActivationFrameAlignment() != 0) {
3378 entry_stack &= -OS::ActivationFrameAlignment();
3379 }
3380 // Store remaining arguments on stack, from low to high memory.
3381 intptr_t* stack_argument = reinterpret_cast<intptr_t*>(entry_stack);
3382 for (int i = 4; i < argument_count; i++) {
3383 stack_argument[i - 4] = va_arg(parameters, int32_t);
3384 }
3385 va_end(parameters);
3386 set_register(sp, entry_stack);
3387
3388 CallInternal(entry);
3384 3389
3385 // Pop stack passed arguments. 3390 // Pop stack passed arguments.
3386 CHECK_EQ(entry_stack, get_register(sp)); 3391 CHECK_EQ(entry_stack, get_register(sp));
3387 set_register(sp, original_stack); 3392 set_register(sp, original_stack);
3388 3393
3389 int32_t result = get_register(r0); 3394 int32_t result = get_register(r0);
3390 return result; 3395 return result;
3391 } 3396 }
3392 3397
3393 3398
3399 double Simulator::CallFP(byte* entry, double d0, double d1) {
3400 if (use_eabi_hardfloat()) {
3401 set_d_register_from_double(0, d0);
3402 set_d_register_from_double(1, d1);
3403 } else {
3404 int buffer[2];
3405 ASSERT(sizeof(buffer[0]) * 2 == sizeof(d0));
3406 memcpy(buffer, &d0, sizeof(d0));
3407 set_dw_register(0, buffer);
3408 memcpy(buffer, &d1, sizeof(d1));
3409 set_dw_register(2, buffer);
3410 }
3411 CallInternal(entry);
3412 if (use_eabi_hardfloat()) {
3413 return get_double_from_d_register(0);
3414 } else {
3415 return get_double_from_register_pair(0);
3416 }
3417 }
3418
3419
3394 uintptr_t Simulator::PushAddress(uintptr_t address) { 3420 uintptr_t Simulator::PushAddress(uintptr_t address) {
3395 int new_sp = get_register(sp) - sizeof(uintptr_t); 3421 int new_sp = get_register(sp) - sizeof(uintptr_t);
3396 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp); 3422 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp);
3397 *stack_slot = address; 3423 *stack_slot = address;
3398 set_register(sp, new_sp); 3424 set_register(sp, new_sp);
3399 return new_sp; 3425 return new_sp;
3400 } 3426 }
3401 3427
3402 3428
3403 uintptr_t Simulator::PopAddress() { 3429 uintptr_t Simulator::PopAddress() {
3404 int current_sp = get_register(sp); 3430 int current_sp = get_register(sp);
3405 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 3431 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
3406 uintptr_t address = *stack_slot; 3432 uintptr_t address = *stack_slot;
3407 set_register(sp, current_sp + sizeof(uintptr_t)); 3433 set_register(sp, current_sp + sizeof(uintptr_t));
3408 return address; 3434 return address;
3409 } 3435 }
3410 3436
3411 } } // namespace v8::internal 3437 } } // namespace v8::internal
3412 3438
3413 #endif // USE_SIMULATOR 3439 #endif // USE_SIMULATOR
3414 3440
3415 #endif // V8_TARGET_ARCH_ARM 3441 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.h ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698