OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 } | 734 } |
735 | 735 |
736 | 736 |
737 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { | 737 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { |
738 i_cache_ = isolate_->simulator_i_cache(); | 738 i_cache_ = isolate_->simulator_i_cache(); |
739 if (i_cache_ == NULL) { | 739 if (i_cache_ == NULL) { |
740 i_cache_ = new v8::internal::HashMap(&ICacheMatch); | 740 i_cache_ = new v8::internal::HashMap(&ICacheMatch); |
741 isolate_->set_simulator_i_cache(i_cache_); | 741 isolate_->set_simulator_i_cache(i_cache_); |
742 } | 742 } |
743 Initialize(isolate); | 743 Initialize(isolate); |
744 // Setup simulator support first. Some of this information is needed to | 744 // Set up simulator support first. Some of this information is needed to |
745 // setup the architecture state. | 745 // setup the architecture state. |
746 size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack | 746 size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack |
747 stack_ = reinterpret_cast<char*>(malloc(stack_size)); | 747 stack_ = reinterpret_cast<char*>(malloc(stack_size)); |
748 pc_modified_ = false; | 748 pc_modified_ = false; |
749 icount_ = 0; | 749 icount_ = 0; |
750 break_pc_ = NULL; | 750 break_pc_ = NULL; |
751 break_instr_ = 0; | 751 break_instr_ = 0; |
752 | 752 |
753 // Setup architecture state. | 753 // Set up architecture state. |
754 // All registers are initialized to zero to start with. | 754 // All registers are initialized to zero to start with. |
755 for (int i = 0; i < num_registers; i++) { | 755 for (int i = 0; i < num_registers; i++) { |
756 registers_[i] = 0; | 756 registers_[i] = 0; |
757 } | 757 } |
758 n_flag_ = false; | 758 n_flag_ = false; |
759 z_flag_ = false; | 759 z_flag_ = false; |
760 c_flag_ = false; | 760 c_flag_ = false; |
761 v_flag_ = false; | 761 v_flag_ = false; |
762 | 762 |
763 // Initializing VFP registers. | 763 // Initializing VFP registers. |
(...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3317 } | 3317 } |
3318 program_counter = get_pc(); | 3318 program_counter = get_pc(); |
3319 } | 3319 } |
3320 } | 3320 } |
3321 } | 3321 } |
3322 | 3322 |
3323 | 3323 |
3324 int32_t Simulator::Call(byte* entry, int argument_count, ...) { | 3324 int32_t Simulator::Call(byte* entry, int argument_count, ...) { |
3325 va_list parameters; | 3325 va_list parameters; |
3326 va_start(parameters, argument_count); | 3326 va_start(parameters, argument_count); |
3327 // Setup arguments | 3327 // Set up arguments |
3328 | 3328 |
3329 // First four arguments passed in registers. | 3329 // First four arguments passed in registers. |
3330 ASSERT(argument_count >= 4); | 3330 ASSERT(argument_count >= 4); |
3331 set_register(r0, va_arg(parameters, int32_t)); | 3331 set_register(r0, va_arg(parameters, int32_t)); |
3332 set_register(r1, va_arg(parameters, int32_t)); | 3332 set_register(r1, va_arg(parameters, int32_t)); |
3333 set_register(r2, va_arg(parameters, int32_t)); | 3333 set_register(r2, va_arg(parameters, int32_t)); |
3334 set_register(r3, va_arg(parameters, int32_t)); | 3334 set_register(r3, va_arg(parameters, int32_t)); |
3335 | 3335 |
3336 // Remaining arguments passed on stack. | 3336 // Remaining arguments passed on stack. |
3337 int original_stack = get_register(sp); | 3337 int original_stack = get_register(sp); |
(...skipping 22 matching lines...) Expand all Loading... |
3360 // simulator code and therefore is regarded as a callee-saved register. | 3360 // simulator code and therefore is regarded as a callee-saved register. |
3361 int32_t r4_val = get_register(r4); | 3361 int32_t r4_val = get_register(r4); |
3362 int32_t r5_val = get_register(r5); | 3362 int32_t r5_val = get_register(r5); |
3363 int32_t r6_val = get_register(r6); | 3363 int32_t r6_val = get_register(r6); |
3364 int32_t r7_val = get_register(r7); | 3364 int32_t r7_val = get_register(r7); |
3365 int32_t r8_val = get_register(r8); | 3365 int32_t r8_val = get_register(r8); |
3366 int32_t r9_val = get_register(r9); | 3366 int32_t r9_val = get_register(r9); |
3367 int32_t r10_val = get_register(r10); | 3367 int32_t r10_val = get_register(r10); |
3368 int32_t r11_val = get_register(r11); | 3368 int32_t r11_val = get_register(r11); |
3369 | 3369 |
3370 // Setup the callee-saved registers with a known value. To be able to check | 3370 // Set up the callee-saved registers with a known value. To be able to check |
3371 // that they are preserved properly across JS execution. | 3371 // that they are preserved properly across JS execution. |
3372 int32_t callee_saved_value = icount_; | 3372 int32_t callee_saved_value = icount_; |
3373 set_register(r4, callee_saved_value); | 3373 set_register(r4, callee_saved_value); |
3374 set_register(r5, callee_saved_value); | 3374 set_register(r5, callee_saved_value); |
3375 set_register(r6, callee_saved_value); | 3375 set_register(r6, callee_saved_value); |
3376 set_register(r7, callee_saved_value); | 3376 set_register(r7, callee_saved_value); |
3377 set_register(r8, callee_saved_value); | 3377 set_register(r8, callee_saved_value); |
3378 set_register(r9, callee_saved_value); | 3378 set_register(r9, callee_saved_value); |
3379 set_register(r10, callee_saved_value); | 3379 set_register(r10, callee_saved_value); |
3380 set_register(r11, callee_saved_value); | 3380 set_register(r11, callee_saved_value); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3426 uintptr_t address = *stack_slot; | 3426 uintptr_t address = *stack_slot; |
3427 set_register(sp, current_sp + sizeof(uintptr_t)); | 3427 set_register(sp, current_sp + sizeof(uintptr_t)); |
3428 return address; | 3428 return address; |
3429 } | 3429 } |
3430 | 3430 |
3431 } } // namespace v8::internal | 3431 } } // namespace v8::internal |
3432 | 3432 |
3433 #endif // USE_SIMULATOR | 3433 #endif // USE_SIMULATOR |
3434 | 3434 |
3435 #endif // V8_TARGET_ARCH_ARM | 3435 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |