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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 } | 881 } |
882 | 882 |
883 | 883 |
884 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { | 884 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { |
885 i_cache_ = isolate_->simulator_i_cache(); | 885 i_cache_ = isolate_->simulator_i_cache(); |
886 if (i_cache_ == NULL) { | 886 if (i_cache_ == NULL) { |
887 i_cache_ = new v8::internal::HashMap(&ICacheMatch); | 887 i_cache_ = new v8::internal::HashMap(&ICacheMatch); |
888 isolate_->set_simulator_i_cache(i_cache_); | 888 isolate_->set_simulator_i_cache(i_cache_); |
889 } | 889 } |
890 Initialize(isolate); | 890 Initialize(isolate); |
891 // Setup simulator support first. Some of this information is needed to | 891 // Set up simulator support first. Some of this information is needed to |
892 // setup the architecture state. | 892 // setup the architecture state. |
893 stack_ = reinterpret_cast<char*>(malloc(stack_size_)); | 893 stack_ = reinterpret_cast<char*>(malloc(stack_size_)); |
894 pc_modified_ = false; | 894 pc_modified_ = false; |
895 icount_ = 0; | 895 icount_ = 0; |
896 break_count_ = 0; | 896 break_count_ = 0; |
897 break_pc_ = NULL; | 897 break_pc_ = NULL; |
898 break_instr_ = 0; | 898 break_instr_ = 0; |
899 | 899 |
900 // Setup architecture state. | 900 // Set up architecture state. |
901 // All registers are initialized to zero to start with. | 901 // All registers are initialized to zero to start with. |
902 for (int i = 0; i < kNumSimuRegisters; i++) { | 902 for (int i = 0; i < kNumSimuRegisters; i++) { |
903 registers_[i] = 0; | 903 registers_[i] = 0; |
904 } | 904 } |
905 for (int i = 0; i < kNumFPURegisters; i++) { | 905 for (int i = 0; i < kNumFPURegisters; i++) { |
906 FPUregisters_[i] = 0; | 906 FPUregisters_[i] = 0; |
907 } | 907 } |
908 FCSR_ = 0; | 908 FCSR_ = 0; |
909 | 909 |
910 // The sp is initialized to point to the bottom (high address) of the | 910 // The sp is initialized to point to the bottom (high address) of the |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 | 1937 |
1938 // For break and trap instructions. | 1938 // For break and trap instructions. |
1939 bool do_interrupt = false; | 1939 bool do_interrupt = false; |
1940 | 1940 |
1941 // For jr and jalr. | 1941 // For jr and jalr. |
1942 // Get current pc. | 1942 // Get current pc. |
1943 int32_t current_pc = get_pc(); | 1943 int32_t current_pc = get_pc(); |
1944 // Next pc | 1944 // Next pc |
1945 int32_t next_pc = 0; | 1945 int32_t next_pc = 0; |
1946 | 1946 |
1947 // Setup the variables if needed before executing the instruction. | 1947 // Set up the variables if needed before executing the instruction. |
1948 ConfigureTypeRegister(instr, | 1948 ConfigureTypeRegister(instr, |
1949 alu_out, | 1949 alu_out, |
1950 i64hilo, | 1950 i64hilo, |
1951 u64hilo, | 1951 u64hilo, |
1952 next_pc, | 1952 next_pc, |
1953 do_interrupt); | 1953 do_interrupt); |
1954 | 1954 |
1955 // ---------- Raise exceptions triggered. | 1955 // ---------- Raise exceptions triggered. |
1956 SignalExceptions(); | 1956 SignalExceptions(); |
1957 | 1957 |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 } | 2704 } |
2705 program_counter = get_pc(); | 2705 program_counter = get_pc(); |
2706 } | 2706 } |
2707 } | 2707 } |
2708 } | 2708 } |
2709 | 2709 |
2710 | 2710 |
2711 int32_t Simulator::Call(byte* entry, int argument_count, ...) { | 2711 int32_t Simulator::Call(byte* entry, int argument_count, ...) { |
2712 va_list parameters; | 2712 va_list parameters; |
2713 va_start(parameters, argument_count); | 2713 va_start(parameters, argument_count); |
2714 // Setup arguments. | 2714 // Set up arguments. |
2715 | 2715 |
2716 // First four arguments passed in registers. | 2716 // First four arguments passed in registers. |
2717 ASSERT(argument_count >= 4); | 2717 ASSERT(argument_count >= 4); |
2718 set_register(a0, va_arg(parameters, int32_t)); | 2718 set_register(a0, va_arg(parameters, int32_t)); |
2719 set_register(a1, va_arg(parameters, int32_t)); | 2719 set_register(a1, va_arg(parameters, int32_t)); |
2720 set_register(a2, va_arg(parameters, int32_t)); | 2720 set_register(a2, va_arg(parameters, int32_t)); |
2721 set_register(a3, va_arg(parameters, int32_t)); | 2721 set_register(a3, va_arg(parameters, int32_t)); |
2722 | 2722 |
2723 // Remaining arguments passed on stack. | 2723 // Remaining arguments passed on stack. |
2724 int original_stack = get_register(sp); | 2724 int original_stack = get_register(sp); |
(...skipping 26 matching lines...) Expand all Loading... |
2751 int32_t s2_val = get_register(s2); | 2751 int32_t s2_val = get_register(s2); |
2752 int32_t s3_val = get_register(s3); | 2752 int32_t s3_val = get_register(s3); |
2753 int32_t s4_val = get_register(s4); | 2753 int32_t s4_val = get_register(s4); |
2754 int32_t s5_val = get_register(s5); | 2754 int32_t s5_val = get_register(s5); |
2755 int32_t s6_val = get_register(s6); | 2755 int32_t s6_val = get_register(s6); |
2756 int32_t s7_val = get_register(s7); | 2756 int32_t s7_val = get_register(s7); |
2757 int32_t gp_val = get_register(gp); | 2757 int32_t gp_val = get_register(gp); |
2758 int32_t sp_val = get_register(sp); | 2758 int32_t sp_val = get_register(sp); |
2759 int32_t fp_val = get_register(fp); | 2759 int32_t fp_val = get_register(fp); |
2760 | 2760 |
2761 // Setup the callee-saved registers with a known value. To be able to check | 2761 // Set up the callee-saved registers with a known value. To be able to check |
2762 // that they are preserved properly across JS execution. | 2762 // that they are preserved properly across JS execution. |
2763 int32_t callee_saved_value = icount_; | 2763 int32_t callee_saved_value = icount_; |
2764 set_register(s0, callee_saved_value); | 2764 set_register(s0, callee_saved_value); |
2765 set_register(s1, callee_saved_value); | 2765 set_register(s1, callee_saved_value); |
2766 set_register(s2, callee_saved_value); | 2766 set_register(s2, callee_saved_value); |
2767 set_register(s3, callee_saved_value); | 2767 set_register(s3, callee_saved_value); |
2768 set_register(s4, callee_saved_value); | 2768 set_register(s4, callee_saved_value); |
2769 set_register(s5, callee_saved_value); | 2769 set_register(s5, callee_saved_value); |
2770 set_register(s6, callee_saved_value); | 2770 set_register(s6, callee_saved_value); |
2771 set_register(s7, callee_saved_value); | 2771 set_register(s7, callee_saved_value); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 } | 2827 } |
2828 | 2828 |
2829 | 2829 |
2830 #undef UNSUPPORTED | 2830 #undef UNSUPPORTED |
2831 | 2831 |
2832 } } // namespace v8::internal | 2832 } } // namespace v8::internal |
2833 | 2833 |
2834 #endif // USE_SIMULATOR | 2834 #endif // USE_SIMULATOR |
2835 | 2835 |
2836 #endif // V8_TARGET_ARCH_MIPS | 2836 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |