OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // with GCC. A different convention is used on 64-bit windows. | 88 // with GCC. A different convention is used on 64-bit windows. |
89 | 89 |
90 typedef int (*F0)(); | 90 typedef int (*F0)(); |
91 | 91 |
92 #define __ masm-> | 92 #define __ masm-> |
93 | 93 |
94 | 94 |
95 static void EntryCode(MacroAssembler* masm) { | 95 static void EntryCode(MacroAssembler* masm) { |
96 // Smi constant register is callee save. | 96 // Smi constant register is callee save. |
97 __ push(v8::internal::kSmiConstantRegister); | 97 __ push(v8::internal::kSmiConstantRegister); |
| 98 __ push(v8::internal::kRootRegister); |
98 __ InitializeSmiConstantRegister(); | 99 __ InitializeSmiConstantRegister(); |
99 __ InitializeRootRegister(); | 100 __ InitializeRootRegister(); |
100 } | 101 } |
101 | 102 |
102 | 103 |
103 static void ExitCode(MacroAssembler* masm) { | 104 static void ExitCode(MacroAssembler* masm) { |
104 // Return -1 if kSmiConstantRegister was clobbered during the test. | 105 // Return -1 if kSmiConstantRegister was clobbered during the test. |
105 __ Move(rdx, Smi::FromInt(1)); | 106 __ Move(rdx, Smi::FromInt(1)); |
106 __ cmpq(rdx, v8::internal::kSmiConstantRegister); | 107 __ cmpq(rdx, v8::internal::kSmiConstantRegister); |
107 __ movq(rdx, Immediate(-1)); | 108 __ movq(rdx, Immediate(-1)); |
108 __ cmovq(not_equal, rax, rdx); | 109 __ cmovq(not_equal, rax, rdx); |
| 110 __ pop(v8::internal::kRootRegister); |
109 __ pop(v8::internal::kSmiConstantRegister); | 111 __ pop(v8::internal::kSmiConstantRegister); |
110 } | 112 } |
111 | 113 |
112 | 114 |
113 TEST(Smi) { | 115 TEST(Smi) { |
114 // Check that C++ Smi operations work as expected. | 116 // Check that C++ Smi operations work as expected. |
115 int64_t test_numbers[] = { | 117 int64_t test_numbers[] = { |
116 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, | 118 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, |
117 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, | 119 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, |
118 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 | 120 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 |
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 CodeDesc desc; | 2490 CodeDesc desc; |
2489 masm->GetCode(&desc); | 2491 masm->GetCode(&desc); |
2490 // Call the function from C++. | 2492 // Call the function from C++. |
2491 int result = FUNCTION_CAST<F0>(buffer)(); | 2493 int result = FUNCTION_CAST<F0>(buffer)(); |
2492 CHECK_EQ(0, result); | 2494 CHECK_EQ(0, result); |
2493 } | 2495 } |
2494 | 2496 |
2495 | 2497 |
2496 | 2498 |
2497 #undef __ | 2499 #undef __ |
OLD | NEW |