| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 using v8::internal::rbx; | 50 using v8::internal::rbx; |
| 51 using v8::internal::rsi; | 51 using v8::internal::rsi; |
| 52 using v8::internal::rdi; | 52 using v8::internal::rdi; |
| 53 using v8::internal::rcx; | 53 using v8::internal::rcx; |
| 54 using v8::internal::rdx; | 54 using v8::internal::rdx; |
| 55 using v8::internal::rbp; | 55 using v8::internal::rbp; |
| 56 using v8::internal::rsp; | 56 using v8::internal::rsp; |
| 57 using v8::internal::r8; | 57 using v8::internal::r8; |
| 58 using v8::internal::r9; | 58 using v8::internal::r9; |
| 59 using v8::internal::r11; | 59 using v8::internal::r11; |
| 60 using v8::internal::r12; // Remember: r12..r15 are callee save! | 60 using v8::internal::r12; |
| 61 using v8::internal::r13; | 61 using v8::internal::r13; |
| 62 using v8::internal::r14; | 62 using v8::internal::r14; |
| 63 using v8::internal::r15; | |
| 64 using v8::internal::times_pointer_size; | 63 using v8::internal::times_pointer_size; |
| 65 using v8::internal::FUNCTION_CAST; | 64 using v8::internal::FUNCTION_CAST; |
| 66 using v8::internal::CodeDesc; | 65 using v8::internal::CodeDesc; |
| 67 using v8::internal::less_equal; | 66 using v8::internal::less_equal; |
| 68 using v8::internal::not_equal; | 67 using v8::internal::not_equal; |
| 69 using v8::internal::not_zero; | 68 using v8::internal::not_zero; |
| 70 using v8::internal::greater; | 69 using v8::internal::greater; |
| 71 using v8::internal::greater_equal; | 70 using v8::internal::greater_equal; |
| 72 using v8::internal::carry; | 71 using v8::internal::carry; |
| 73 using v8::internal::not_carry; | 72 using v8::internal::not_carry; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 85 // The AMD64 calling convention is used, with the first five arguments | 84 // The AMD64 calling convention is used, with the first five arguments |
| 86 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in | 85 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in |
| 87 // the XMM registers. The return value is in RAX. | 86 // the XMM registers. The return value is in RAX. |
| 88 // This calling convention is used on Linux, with GCC, and on Mac OS, | 87 // This calling convention is used on Linux, with GCC, and on Mac OS, |
| 89 // with GCC. A different convention is used on 64-bit windows. | 88 // with GCC. A different convention is used on 64-bit windows. |
| 90 | 89 |
| 91 typedef int (*F0)(); | 90 typedef int (*F0)(); |
| 92 | 91 |
| 93 #define __ masm-> | 92 #define __ masm-> |
| 94 | 93 |
| 94 |
| 95 static void EntryCode(MacroAssembler* masm) { |
| 96 // Smi constant register is callee save. |
| 97 __ push(v8::internal::kSmiConstantRegister); |
| 98 __ InitializeSmiConstantRegister(); |
| 99 } |
| 100 |
| 101 |
| 102 static void ExitCode(MacroAssembler* masm) { |
| 103 // Return -1 if kSmiConstantRegister was clobbered during the test. |
| 104 __ Move(rdx, Smi::FromInt(1)); |
| 105 __ cmpq(rdx, v8::internal::kSmiConstantRegister); |
| 106 __ movq(rdx, Immediate(-1)); |
| 107 __ cmovq(not_equal, rax, rdx); |
| 108 __ pop(v8::internal::kSmiConstantRegister); |
| 109 } |
| 110 |
| 111 |
| 95 TEST(Smi) { | 112 TEST(Smi) { |
| 96 // Check that C++ Smi operations work as expected. | 113 // Check that C++ Smi operations work as expected. |
| 97 int64_t test_numbers[] = { | 114 int64_t test_numbers[] = { |
| 98 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, | 115 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, |
| 99 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, | 116 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, |
| 100 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 | 117 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 |
| 101 }; | 118 }; |
| 102 int test_number_count = 15; | 119 int test_number_count = 15; |
| 103 for (int i = 0; i < test_number_count; i++) { | 120 for (int i = 0; i < test_number_count; i++) { |
| 104 int64_t number = test_numbers[i]; | 121 int64_t number = test_numbers[i]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 132 // Allocate an executable page of memory. | 149 // Allocate an executable page of memory. |
| 133 size_t actual_size; | 150 size_t actual_size; |
| 134 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 151 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 135 &actual_size, | 152 &actual_size, |
| 136 true)); | 153 true)); |
| 137 CHECK(buffer); | 154 CHECK(buffer); |
| 138 HandleScope handles; | 155 HandleScope handles; |
| 139 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 156 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 140 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. | 157 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
| 141 masm->set_allow_stub_calls(false); | 158 masm->set_allow_stub_calls(false); |
| 159 EntryCode(masm); |
| 142 Label exit; | 160 Label exit; |
| 143 | 161 |
| 144 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0)); | 162 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0)); |
| 145 TestMoveSmi(masm, &exit, 2, Smi::FromInt(127)); | 163 TestMoveSmi(masm, &exit, 2, Smi::FromInt(127)); |
| 146 TestMoveSmi(masm, &exit, 3, Smi::FromInt(128)); | 164 TestMoveSmi(masm, &exit, 3, Smi::FromInt(128)); |
| 147 TestMoveSmi(masm, &exit, 4, Smi::FromInt(255)); | 165 TestMoveSmi(masm, &exit, 4, Smi::FromInt(255)); |
| 148 TestMoveSmi(masm, &exit, 5, Smi::FromInt(256)); | 166 TestMoveSmi(masm, &exit, 5, Smi::FromInt(256)); |
| 149 TestMoveSmi(masm, &exit, 6, Smi::FromInt(Smi::kMaxValue)); | 167 TestMoveSmi(masm, &exit, 6, Smi::FromInt(Smi::kMaxValue)); |
| 150 TestMoveSmi(masm, &exit, 7, Smi::FromInt(-1)); | 168 TestMoveSmi(masm, &exit, 7, Smi::FromInt(-1)); |
| 151 TestMoveSmi(masm, &exit, 8, Smi::FromInt(-128)); | 169 TestMoveSmi(masm, &exit, 8, Smi::FromInt(-128)); |
| 152 TestMoveSmi(masm, &exit, 9, Smi::FromInt(-129)); | 170 TestMoveSmi(masm, &exit, 9, Smi::FromInt(-129)); |
| 153 TestMoveSmi(masm, &exit, 10, Smi::FromInt(-256)); | 171 TestMoveSmi(masm, &exit, 10, Smi::FromInt(-256)); |
| 154 TestMoveSmi(masm, &exit, 11, Smi::FromInt(-257)); | 172 TestMoveSmi(masm, &exit, 11, Smi::FromInt(-257)); |
| 155 TestMoveSmi(masm, &exit, 12, Smi::FromInt(Smi::kMinValue)); | 173 TestMoveSmi(masm, &exit, 12, Smi::FromInt(Smi::kMinValue)); |
| 156 | 174 |
| 157 __ xor_(rax, rax); // Success. | 175 __ xor_(rax, rax); // Success. |
| 158 __ bind(&exit); | 176 __ bind(&exit); |
| 177 ExitCode(masm); |
| 159 __ ret(0); | 178 __ ret(0); |
| 160 | 179 |
| 161 CodeDesc desc; | 180 CodeDesc desc; |
| 162 masm->GetCode(&desc); | 181 masm->GetCode(&desc); |
| 163 // Call the function from C++. | 182 // Call the function from C++. |
| 164 int result = FUNCTION_CAST<F0>(buffer)(); | 183 int result = FUNCTION_CAST<F0>(buffer)(); |
| 165 CHECK_EQ(0, result); | 184 CHECK_EQ(0, result); |
| 166 } | 185 } |
| 167 | 186 |
| 168 | 187 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 byte* buffer = | 237 byte* buffer = |
| 219 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 238 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 220 &actual_size, | 239 &actual_size, |
| 221 true)); | 240 true)); |
| 222 CHECK(buffer); | 241 CHECK(buffer); |
| 223 HandleScope handles; | 242 HandleScope handles; |
| 224 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 243 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 225 | 244 |
| 226 MacroAssembler* masm = &assembler; | 245 MacroAssembler* masm = &assembler; |
| 227 masm->set_allow_stub_calls(false); | 246 masm->set_allow_stub_calls(false); |
| 247 EntryCode(masm); |
| 228 Label exit; | 248 Label exit; |
| 229 | 249 |
| 230 TestSmiCompare(masm, &exit, 0x10, 0, 0); | 250 TestSmiCompare(masm, &exit, 0x10, 0, 0); |
| 231 TestSmiCompare(masm, &exit, 0x20, 0, 1); | 251 TestSmiCompare(masm, &exit, 0x20, 0, 1); |
| 232 TestSmiCompare(masm, &exit, 0x30, 1, 0); | 252 TestSmiCompare(masm, &exit, 0x30, 1, 0); |
| 233 TestSmiCompare(masm, &exit, 0x40, 1, 1); | 253 TestSmiCompare(masm, &exit, 0x40, 1, 1); |
| 234 TestSmiCompare(masm, &exit, 0x50, 0, -1); | 254 TestSmiCompare(masm, &exit, 0x50, 0, -1); |
| 235 TestSmiCompare(masm, &exit, 0x60, -1, 0); | 255 TestSmiCompare(masm, &exit, 0x60, -1, 0); |
| 236 TestSmiCompare(masm, &exit, 0x70, -1, -1); | 256 TestSmiCompare(masm, &exit, 0x70, -1, -1); |
| 237 TestSmiCompare(masm, &exit, 0x80, 0, Smi::kMinValue); | 257 TestSmiCompare(masm, &exit, 0x80, 0, Smi::kMinValue); |
| 238 TestSmiCompare(masm, &exit, 0x90, Smi::kMinValue, 0); | 258 TestSmiCompare(masm, &exit, 0x90, Smi::kMinValue, 0); |
| 239 TestSmiCompare(masm, &exit, 0xA0, 0, Smi::kMaxValue); | 259 TestSmiCompare(masm, &exit, 0xA0, 0, Smi::kMaxValue); |
| 240 TestSmiCompare(masm, &exit, 0xB0, Smi::kMaxValue, 0); | 260 TestSmiCompare(masm, &exit, 0xB0, Smi::kMaxValue, 0); |
| 241 TestSmiCompare(masm, &exit, 0xC0, -1, Smi::kMinValue); | 261 TestSmiCompare(masm, &exit, 0xC0, -1, Smi::kMinValue); |
| 242 TestSmiCompare(masm, &exit, 0xD0, Smi::kMinValue, -1); | 262 TestSmiCompare(masm, &exit, 0xD0, Smi::kMinValue, -1); |
| 243 TestSmiCompare(masm, &exit, 0xE0, -1, Smi::kMaxValue); | 263 TestSmiCompare(masm, &exit, 0xE0, -1, Smi::kMaxValue); |
| 244 TestSmiCompare(masm, &exit, 0xF0, Smi::kMaxValue, -1); | 264 TestSmiCompare(masm, &exit, 0xF0, Smi::kMaxValue, -1); |
| 245 TestSmiCompare(masm, &exit, 0x100, Smi::kMinValue, Smi::kMinValue); | 265 TestSmiCompare(masm, &exit, 0x100, Smi::kMinValue, Smi::kMinValue); |
| 246 TestSmiCompare(masm, &exit, 0x110, Smi::kMinValue, Smi::kMaxValue); | 266 TestSmiCompare(masm, &exit, 0x110, Smi::kMinValue, Smi::kMaxValue); |
| 247 TestSmiCompare(masm, &exit, 0x120, Smi::kMaxValue, Smi::kMinValue); | 267 TestSmiCompare(masm, &exit, 0x120, Smi::kMaxValue, Smi::kMinValue); |
| 248 TestSmiCompare(masm, &exit, 0x130, Smi::kMaxValue, Smi::kMaxValue); | 268 TestSmiCompare(masm, &exit, 0x130, Smi::kMaxValue, Smi::kMaxValue); |
| 249 | 269 |
| 250 __ xor_(rax, rax); // Success. | 270 __ xor_(rax, rax); // Success. |
| 251 __ bind(&exit); | 271 __ bind(&exit); |
| 272 ExitCode(masm); |
| 252 __ ret(0); | 273 __ ret(0); |
| 253 | 274 |
| 254 CodeDesc desc; | 275 CodeDesc desc; |
| 255 masm->GetCode(&desc); | 276 masm->GetCode(&desc); |
| 256 // Call the function from C++. | 277 // Call the function from C++. |
| 257 int result = FUNCTION_CAST<F0>(buffer)(); | 278 int result = FUNCTION_CAST<F0>(buffer)(); |
| 258 CHECK_EQ(0, result); | 279 CHECK_EQ(0, result); |
| 259 } | 280 } |
| 260 | 281 |
| 261 | 282 |
| 262 | 283 |
| 263 TEST(Integer32ToSmi) { | 284 TEST(Integer32ToSmi) { |
| 264 // Allocate an executable page of memory. | 285 // Allocate an executable page of memory. |
| 265 size_t actual_size; | 286 size_t actual_size; |
| 266 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 287 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 267 &actual_size, | 288 &actual_size, |
| 268 true)); | 289 true)); |
| 269 CHECK(buffer); | 290 CHECK(buffer); |
| 270 HandleScope handles; | 291 HandleScope handles; |
| 271 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 292 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 272 | 293 |
| 273 MacroAssembler* masm = &assembler; | 294 MacroAssembler* masm = &assembler; |
| 274 masm->set_allow_stub_calls(false); | 295 masm->set_allow_stub_calls(false); |
| 296 EntryCode(masm); |
| 275 Label exit; | 297 Label exit; |
| 276 | 298 |
| 277 __ movq(rax, Immediate(1)); // Test number. | 299 __ movq(rax, Immediate(1)); // Test number. |
| 278 __ movl(rcx, Immediate(0)); | 300 __ movl(rcx, Immediate(0)); |
| 279 __ Integer32ToSmi(rcx, rcx); | 301 __ Integer32ToSmi(rcx, rcx); |
| 280 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); | 302 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); |
| 281 __ SmiCompare(rcx, rdx); | 303 __ SmiCompare(rcx, rdx); |
| 282 __ j(not_equal, &exit); | 304 __ j(not_equal, &exit); |
| 283 | 305 |
| 284 __ movq(rax, Immediate(2)); // Test number. | 306 __ movq(rax, Immediate(2)); // Test number. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 __ movq(rax, Immediate(10)); // Test number. | 364 __ movq(rax, Immediate(10)); // Test number. |
| 343 __ movl(rcx, Immediate(Smi::kMinValue)); | 365 __ movl(rcx, Immediate(Smi::kMinValue)); |
| 344 __ Integer32ToSmi(r8, rcx); | 366 __ Integer32ToSmi(r8, rcx); |
| 345 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); | 367 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); |
| 346 __ SmiCompare(r8, rdx); | 368 __ SmiCompare(r8, rdx); |
| 347 __ j(not_equal, &exit); | 369 __ j(not_equal, &exit); |
| 348 | 370 |
| 349 | 371 |
| 350 __ xor_(rax, rax); // Success. | 372 __ xor_(rax, rax); // Success. |
| 351 __ bind(&exit); | 373 __ bind(&exit); |
| 374 ExitCode(masm); |
| 352 __ ret(0); | 375 __ ret(0); |
| 353 | 376 |
| 354 CodeDesc desc; | 377 CodeDesc desc; |
| 355 masm->GetCode(&desc); | 378 masm->GetCode(&desc); |
| 356 // Call the function from C++. | 379 // Call the function from C++. |
| 357 int result = FUNCTION_CAST<F0>(buffer)(); | 380 int result = FUNCTION_CAST<F0>(buffer)(); |
| 358 CHECK_EQ(0, result); | 381 CHECK_EQ(0, result); |
| 359 } | 382 } |
| 360 | 383 |
| 361 | 384 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 390 size_t actual_size; | 413 size_t actual_size; |
| 391 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 414 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 392 &actual_size, | 415 &actual_size, |
| 393 true)); | 416 true)); |
| 394 CHECK(buffer); | 417 CHECK(buffer); |
| 395 HandleScope handles; | 418 HandleScope handles; |
| 396 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 419 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 397 | 420 |
| 398 MacroAssembler* masm = &assembler; | 421 MacroAssembler* masm = &assembler; |
| 399 masm->set_allow_stub_calls(false); | 422 masm->set_allow_stub_calls(false); |
| 423 EntryCode(masm); |
| 400 Label exit; | 424 Label exit; |
| 401 | 425 |
| 402 int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2; | 426 int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2; |
| 403 | 427 |
| 404 TestI64PlusConstantToSmi(masm, &exit, 0x10, 0, 0); | 428 TestI64PlusConstantToSmi(masm, &exit, 0x10, 0, 0); |
| 405 TestI64PlusConstantToSmi(masm, &exit, 0x20, 0, 1); | 429 TestI64PlusConstantToSmi(masm, &exit, 0x20, 0, 1); |
| 406 TestI64PlusConstantToSmi(masm, &exit, 0x30, 1, 0); | 430 TestI64PlusConstantToSmi(masm, &exit, 0x30, 1, 0); |
| 407 TestI64PlusConstantToSmi(masm, &exit, 0x40, Smi::kMaxValue - 5, 5); | 431 TestI64PlusConstantToSmi(masm, &exit, 0x40, Smi::kMaxValue - 5, 5); |
| 408 TestI64PlusConstantToSmi(masm, &exit, 0x50, Smi::kMinValue + 5, 5); | 432 TestI64PlusConstantToSmi(masm, &exit, 0x50, Smi::kMinValue + 5, 5); |
| 409 TestI64PlusConstantToSmi(masm, &exit, 0x60, twice_max, -Smi::kMaxValue); | 433 TestI64PlusConstantToSmi(masm, &exit, 0x60, twice_max, -Smi::kMaxValue); |
| 410 TestI64PlusConstantToSmi(masm, &exit, 0x70, -twice_max, Smi::kMaxValue); | 434 TestI64PlusConstantToSmi(masm, &exit, 0x70, -twice_max, Smi::kMaxValue); |
| 411 TestI64PlusConstantToSmi(masm, &exit, 0x80, 0, Smi::kMinValue); | 435 TestI64PlusConstantToSmi(masm, &exit, 0x80, 0, Smi::kMinValue); |
| 412 TestI64PlusConstantToSmi(masm, &exit, 0x90, 0, Smi::kMaxValue); | 436 TestI64PlusConstantToSmi(masm, &exit, 0x90, 0, Smi::kMaxValue); |
| 413 TestI64PlusConstantToSmi(masm, &exit, 0xA0, Smi::kMinValue, 0); | 437 TestI64PlusConstantToSmi(masm, &exit, 0xA0, Smi::kMinValue, 0); |
| 414 TestI64PlusConstantToSmi(masm, &exit, 0xB0, Smi::kMaxValue, 0); | 438 TestI64PlusConstantToSmi(masm, &exit, 0xB0, Smi::kMaxValue, 0); |
| 415 TestI64PlusConstantToSmi(masm, &exit, 0xC0, twice_max, Smi::kMinValue); | 439 TestI64PlusConstantToSmi(masm, &exit, 0xC0, twice_max, Smi::kMinValue); |
| 416 | 440 |
| 417 __ xor_(rax, rax); // Success. | 441 __ xor_(rax, rax); // Success. |
| 418 __ bind(&exit); | 442 __ bind(&exit); |
| 443 ExitCode(masm); |
| 419 __ ret(0); | 444 __ ret(0); |
| 420 | 445 |
| 421 CodeDesc desc; | 446 CodeDesc desc; |
| 422 masm->GetCode(&desc); | 447 masm->GetCode(&desc); |
| 423 // Call the function from C++. | 448 // Call the function from C++. |
| 424 int result = FUNCTION_CAST<F0>(buffer)(); | 449 int result = FUNCTION_CAST<F0>(buffer)(); |
| 425 CHECK_EQ(0, result); | 450 CHECK_EQ(0, result); |
| 426 } | 451 } |
| 427 | 452 |
| 428 | 453 |
| 429 TEST(SmiCheck) { | 454 TEST(SmiCheck) { |
| 430 // Allocate an executable page of memory. | 455 // Allocate an executable page of memory. |
| 431 size_t actual_size; | 456 size_t actual_size; |
| 432 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 457 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 433 &actual_size, | 458 &actual_size, |
| 434 true)); | 459 true)); |
| 435 CHECK(buffer); | 460 CHECK(buffer); |
| 436 HandleScope handles; | 461 HandleScope handles; |
| 437 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 462 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 438 | 463 |
| 439 MacroAssembler* masm = &assembler; | 464 MacroAssembler* masm = &assembler; |
| 440 masm->set_allow_stub_calls(false); | 465 masm->set_allow_stub_calls(false); |
| 466 EntryCode(masm); |
| 441 Label exit; | 467 Label exit; |
| 442 Condition cond; | 468 Condition cond; |
| 443 | 469 |
| 444 __ movl(rax, Immediate(1)); // Test number. | 470 __ movl(rax, Immediate(1)); // Test number. |
| 445 | 471 |
| 446 // CheckSmi | 472 // CheckSmi |
| 447 | 473 |
| 448 __ movl(rcx, Immediate(0)); | 474 __ movl(rcx, Immediate(0)); |
| 449 __ Integer32ToSmi(rcx, rcx); | 475 __ Integer32ToSmi(rcx, rcx); |
| 450 cond = masm->CheckSmi(rcx); | 476 cond = masm->CheckSmi(rcx); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 632 |
| 607 __ incq(rax); | 633 __ incq(rax); |
| 608 __ movq(rcx, Immediate(Smi::kMinValue)); | 634 __ movq(rcx, Immediate(Smi::kMinValue)); |
| 609 cond = masm->CheckInteger32ValidSmiValue(rax); | 635 cond = masm->CheckInteger32ValidSmiValue(rax); |
| 610 __ j(NegateCondition(cond), &exit); | 636 __ j(NegateCondition(cond), &exit); |
| 611 | 637 |
| 612 // Success | 638 // Success |
| 613 __ xor_(rax, rax); | 639 __ xor_(rax, rax); |
| 614 | 640 |
| 615 __ bind(&exit); | 641 __ bind(&exit); |
| 642 ExitCode(masm); |
| 616 __ ret(0); | 643 __ ret(0); |
| 617 | 644 |
| 618 CodeDesc desc; | 645 CodeDesc desc; |
| 619 masm->GetCode(&desc); | 646 masm->GetCode(&desc); |
| 620 // Call the function from C++. | 647 // Call the function from C++. |
| 621 int result = FUNCTION_CAST<F0>(buffer)(); | 648 int result = FUNCTION_CAST<F0>(buffer)(); |
| 622 CHECK_EQ(0, result); | 649 CHECK_EQ(0, result); |
| 623 } | 650 } |
| 624 | 651 |
| 625 | 652 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 byte* buffer = | 703 byte* buffer = |
| 677 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 704 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 678 &actual_size, | 705 &actual_size, |
| 679 true)); | 706 true)); |
| 680 CHECK(buffer); | 707 CHECK(buffer); |
| 681 HandleScope handles; | 708 HandleScope handles; |
| 682 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 709 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 683 | 710 |
| 684 MacroAssembler* masm = &assembler; | 711 MacroAssembler* masm = &assembler; |
| 685 masm->set_allow_stub_calls(false); | 712 masm->set_allow_stub_calls(false); |
| 713 EntryCode(masm); |
| 686 Label exit; | 714 Label exit; |
| 687 | 715 |
| 688 TestSmiNeg(masm, &exit, 0x10, 0); | 716 TestSmiNeg(masm, &exit, 0x10, 0); |
| 689 TestSmiNeg(masm, &exit, 0x20, 1); | 717 TestSmiNeg(masm, &exit, 0x20, 1); |
| 690 TestSmiNeg(masm, &exit, 0x30, -1); | 718 TestSmiNeg(masm, &exit, 0x30, -1); |
| 691 TestSmiNeg(masm, &exit, 0x40, 127); | 719 TestSmiNeg(masm, &exit, 0x40, 127); |
| 692 TestSmiNeg(masm, &exit, 0x50, 65535); | 720 TestSmiNeg(masm, &exit, 0x50, 65535); |
| 693 TestSmiNeg(masm, &exit, 0x60, Smi::kMinValue); | 721 TestSmiNeg(masm, &exit, 0x60, Smi::kMinValue); |
| 694 TestSmiNeg(masm, &exit, 0x70, Smi::kMaxValue); | 722 TestSmiNeg(masm, &exit, 0x70, Smi::kMaxValue); |
| 695 TestSmiNeg(masm, &exit, 0x80, -Smi::kMaxValue); | 723 TestSmiNeg(masm, &exit, 0x80, -Smi::kMaxValue); |
| 696 | 724 |
| 697 __ xor_(rax, rax); // Success. | 725 __ xor_(rax, rax); // Success. |
| 698 __ bind(&exit); | 726 __ bind(&exit); |
| 727 ExitCode(masm); |
| 699 __ ret(0); | 728 __ ret(0); |
| 700 | 729 |
| 701 CodeDesc desc; | 730 CodeDesc desc; |
| 702 masm->GetCode(&desc); | 731 masm->GetCode(&desc); |
| 703 // Call the function from C++. | 732 // Call the function from C++. |
| 704 int result = FUNCTION_CAST<F0>(buffer)(); | 733 int result = FUNCTION_CAST<F0>(buffer)(); |
| 705 CHECK_EQ(0, result); | 734 CHECK_EQ(0, result); |
| 706 } | 735 } |
| 707 | 736 |
| 708 | 737 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 size_t actual_size; | 790 size_t actual_size; |
| 762 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 791 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 763 &actual_size, | 792 &actual_size, |
| 764 true)); | 793 true)); |
| 765 CHECK(buffer); | 794 CHECK(buffer); |
| 766 HandleScope handles; | 795 HandleScope handles; |
| 767 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 796 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 768 | 797 |
| 769 MacroAssembler* masm = &assembler; | 798 MacroAssembler* masm = &assembler; |
| 770 masm->set_allow_stub_calls(false); | 799 masm->set_allow_stub_calls(false); |
| 800 EntryCode(masm); |
| 771 Label exit; | 801 Label exit; |
| 772 | 802 |
| 773 // No-overflow tests. | 803 // No-overflow tests. |
| 774 SmiAddTest(masm, &exit, 0x10, 1, 2); | 804 SmiAddTest(masm, &exit, 0x10, 1, 2); |
| 775 SmiAddTest(masm, &exit, 0x20, 1, -2); | 805 SmiAddTest(masm, &exit, 0x20, 1, -2); |
| 776 SmiAddTest(masm, &exit, 0x30, -1, 2); | 806 SmiAddTest(masm, &exit, 0x30, -1, 2); |
| 777 SmiAddTest(masm, &exit, 0x40, -1, -2); | 807 SmiAddTest(masm, &exit, 0x40, -1, -2); |
| 778 SmiAddTest(masm, &exit, 0x50, 0x1000, 0x2000); | 808 SmiAddTest(masm, &exit, 0x50, 0x1000, 0x2000); |
| 779 SmiAddTest(masm, &exit, 0x60, Smi::kMinValue, 5); | 809 SmiAddTest(masm, &exit, 0x60, Smi::kMinValue, 5); |
| 780 SmiAddTest(masm, &exit, 0x70, Smi::kMaxValue, -5); | 810 SmiAddTest(masm, &exit, 0x70, Smi::kMaxValue, -5); |
| 781 SmiAddTest(masm, &exit, 0x80, Smi::kMaxValue, Smi::kMinValue); | 811 SmiAddTest(masm, &exit, 0x80, Smi::kMaxValue, Smi::kMinValue); |
| 782 | 812 |
| 783 __ xor_(rax, rax); // Success. | 813 __ xor_(rax, rax); // Success. |
| 784 __ bind(&exit); | 814 __ bind(&exit); |
| 815 ExitCode(masm); |
| 785 __ ret(0); | 816 __ ret(0); |
| 786 | 817 |
| 787 CodeDesc desc; | 818 CodeDesc desc; |
| 788 masm->GetCode(&desc); | 819 masm->GetCode(&desc); |
| 789 // Call the function from C++. | 820 // Call the function from C++. |
| 790 int result = FUNCTION_CAST<F0>(buffer)(); | 821 int result = FUNCTION_CAST<F0>(buffer)(); |
| 791 CHECK_EQ(0, result); | 822 CHECK_EQ(0, result); |
| 792 } | 823 } |
| 793 | 824 |
| 794 | 825 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 byte* buffer = | 979 byte* buffer = |
| 949 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 980 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 950 &actual_size, | 981 &actual_size, |
| 951 true)); | 982 true)); |
| 952 CHECK(buffer); | 983 CHECK(buffer); |
| 953 HandleScope handles; | 984 HandleScope handles; |
| 954 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 985 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 955 | 986 |
| 956 MacroAssembler* masm = &assembler; | 987 MacroAssembler* masm = &assembler; |
| 957 masm->set_allow_stub_calls(false); | 988 masm->set_allow_stub_calls(false); |
| 989 EntryCode(masm); |
| 958 Label exit; | 990 Label exit; |
| 959 | 991 |
| 960 SmiSubTest(masm, &exit, 0x10, 1, 2); | 992 SmiSubTest(masm, &exit, 0x10, 1, 2); |
| 961 SmiSubTest(masm, &exit, 0x20, 1, -2); | 993 SmiSubTest(masm, &exit, 0x20, 1, -2); |
| 962 SmiSubTest(masm, &exit, 0x30, -1, 2); | 994 SmiSubTest(masm, &exit, 0x30, -1, 2); |
| 963 SmiSubTest(masm, &exit, 0x40, -1, -2); | 995 SmiSubTest(masm, &exit, 0x40, -1, -2); |
| 964 SmiSubTest(masm, &exit, 0x50, 0x1000, 0x2000); | 996 SmiSubTest(masm, &exit, 0x50, 0x1000, 0x2000); |
| 965 SmiSubTest(masm, &exit, 0x60, Smi::kMinValue, -5); | 997 SmiSubTest(masm, &exit, 0x60, Smi::kMinValue, -5); |
| 966 SmiSubTest(masm, &exit, 0x70, Smi::kMaxValue, 5); | 998 SmiSubTest(masm, &exit, 0x70, Smi::kMaxValue, 5); |
| 967 SmiSubTest(masm, &exit, 0x80, -Smi::kMaxValue, Smi::kMinValue); | 999 SmiSubTest(masm, &exit, 0x80, -Smi::kMaxValue, Smi::kMinValue); |
| 968 SmiSubTest(masm, &exit, 0x90, 0, Smi::kMaxValue); | 1000 SmiSubTest(masm, &exit, 0x90, 0, Smi::kMaxValue); |
| 969 | 1001 |
| 970 SmiSubOverflowTest(masm, &exit, 0xA0, 1); | 1002 SmiSubOverflowTest(masm, &exit, 0xA0, 1); |
| 971 SmiSubOverflowTest(masm, &exit, 0xB0, 1024); | 1003 SmiSubOverflowTest(masm, &exit, 0xB0, 1024); |
| 972 SmiSubOverflowTest(masm, &exit, 0xC0, Smi::kMaxValue); | 1004 SmiSubOverflowTest(masm, &exit, 0xC0, Smi::kMaxValue); |
| 973 SmiSubOverflowTest(masm, &exit, 0xD0, -2); | 1005 SmiSubOverflowTest(masm, &exit, 0xD0, -2); |
| 974 SmiSubOverflowTest(masm, &exit, 0xE0, -42000); | 1006 SmiSubOverflowTest(masm, &exit, 0xE0, -42000); |
| 975 SmiSubOverflowTest(masm, &exit, 0xF0, Smi::kMinValue); | 1007 SmiSubOverflowTest(masm, &exit, 0xF0, Smi::kMinValue); |
| 976 SmiSubOverflowTest(masm, &exit, 0x100, 0); | 1008 SmiSubOverflowTest(masm, &exit, 0x100, 0); |
| 977 | 1009 |
| 978 __ xor_(rax, rax); // Success. | 1010 __ xor_(rax, rax); // Success. |
| 979 __ bind(&exit); | 1011 __ bind(&exit); |
| 1012 ExitCode(masm); |
| 980 __ ret(0); | 1013 __ ret(0); |
| 981 | 1014 |
| 982 CodeDesc desc; | 1015 CodeDesc desc; |
| 983 masm->GetCode(&desc); | 1016 masm->GetCode(&desc); |
| 984 // Call the function from C++. | 1017 // Call the function from C++. |
| 985 int result = FUNCTION_CAST<F0>(buffer)(); | 1018 int result = FUNCTION_CAST<F0>(buffer)(); |
| 986 CHECK_EQ(0, result); | 1019 CHECK_EQ(0, result); |
| 987 } | 1020 } |
| 988 | 1021 |
| 989 | 1022 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 size_t actual_size; | 1068 size_t actual_size; |
| 1036 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1069 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1037 &actual_size, | 1070 &actual_size, |
| 1038 true)); | 1071 true)); |
| 1039 CHECK(buffer); | 1072 CHECK(buffer); |
| 1040 HandleScope handles; | 1073 HandleScope handles; |
| 1041 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1074 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1042 | 1075 |
| 1043 MacroAssembler* masm = &assembler; | 1076 MacroAssembler* masm = &assembler; |
| 1044 masm->set_allow_stub_calls(false); | 1077 masm->set_allow_stub_calls(false); |
| 1078 EntryCode(masm); |
| 1045 Label exit; | 1079 Label exit; |
| 1046 | 1080 |
| 1047 TestSmiMul(masm, &exit, 0x10, 0, 0); | 1081 TestSmiMul(masm, &exit, 0x10, 0, 0); |
| 1048 TestSmiMul(masm, &exit, 0x20, -1, 0); | 1082 TestSmiMul(masm, &exit, 0x20, -1, 0); |
| 1049 TestSmiMul(masm, &exit, 0x30, 0, -1); | 1083 TestSmiMul(masm, &exit, 0x30, 0, -1); |
| 1050 TestSmiMul(masm, &exit, 0x40, -1, -1); | 1084 TestSmiMul(masm, &exit, 0x40, -1, -1); |
| 1051 TestSmiMul(masm, &exit, 0x50, 0x10000, 0x10000); | 1085 TestSmiMul(masm, &exit, 0x50, 0x10000, 0x10000); |
| 1052 TestSmiMul(masm, &exit, 0x60, 0x10000, 0xffff); | 1086 TestSmiMul(masm, &exit, 0x60, 0x10000, 0xffff); |
| 1053 TestSmiMul(masm, &exit, 0x70, 0x10000, 0xffff); | 1087 TestSmiMul(masm, &exit, 0x70, 0x10000, 0xffff); |
| 1054 TestSmiMul(masm, &exit, 0x80, Smi::kMaxValue, -1); | 1088 TestSmiMul(masm, &exit, 0x80, Smi::kMaxValue, -1); |
| 1055 TestSmiMul(masm, &exit, 0x90, Smi::kMaxValue, -2); | 1089 TestSmiMul(masm, &exit, 0x90, Smi::kMaxValue, -2); |
| 1056 TestSmiMul(masm, &exit, 0xa0, Smi::kMaxValue, 2); | 1090 TestSmiMul(masm, &exit, 0xa0, Smi::kMaxValue, 2); |
| 1057 TestSmiMul(masm, &exit, 0xb0, (Smi::kMaxValue / 2), 2); | 1091 TestSmiMul(masm, &exit, 0xb0, (Smi::kMaxValue / 2), 2); |
| 1058 TestSmiMul(masm, &exit, 0xc0, (Smi::kMaxValue / 2) + 1, 2); | 1092 TestSmiMul(masm, &exit, 0xc0, (Smi::kMaxValue / 2) + 1, 2); |
| 1059 TestSmiMul(masm, &exit, 0xd0, (Smi::kMinValue / 2), 2); | 1093 TestSmiMul(masm, &exit, 0xd0, (Smi::kMinValue / 2), 2); |
| 1060 TestSmiMul(masm, &exit, 0xe0, (Smi::kMinValue / 2) - 1, 2); | 1094 TestSmiMul(masm, &exit, 0xe0, (Smi::kMinValue / 2) - 1, 2); |
| 1061 | 1095 |
| 1062 __ xor_(rax, rax); // Success. | 1096 __ xor_(rax, rax); // Success. |
| 1063 __ bind(&exit); | 1097 __ bind(&exit); |
| 1098 ExitCode(masm); |
| 1064 __ ret(0); | 1099 __ ret(0); |
| 1065 | 1100 |
| 1066 CodeDesc desc; | 1101 CodeDesc desc; |
| 1067 masm->GetCode(&desc); | 1102 masm->GetCode(&desc); |
| 1068 // Call the function from C++. | 1103 // Call the function from C++. |
| 1069 int result = FUNCTION_CAST<F0>(buffer)(); | 1104 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1070 CHECK_EQ(0, result); | 1105 CHECK_EQ(0, result); |
| 1071 } | 1106 } |
| 1072 | 1107 |
| 1073 | 1108 |
| 1074 void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1109 void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1075 bool division_by_zero = (y == 0); | 1110 bool division_by_zero = (y == 0); |
| 1076 bool negative_zero = (x == 0 && y < 0); | 1111 bool negative_zero = (x == 0 && y < 0); |
| 1077 #ifdef V8_TARGET_ARCH_X64 | 1112 #ifdef V8_TARGET_ARCH_X64 |
| 1078 bool overflow = (x == Smi::kMinValue && y < 0); // Safe approx. used. | 1113 bool overflow = (x == Smi::kMinValue && y < 0); // Safe approx. used. |
| 1079 #else | 1114 #else |
| 1080 bool overflow = (x == Smi::kMinValue && y == -1); | 1115 bool overflow = (x == Smi::kMinValue && y == -1); |
| 1081 #endif | 1116 #endif |
| 1082 bool fraction = !division_by_zero && !overflow && (x % y != 0); | 1117 bool fraction = !division_by_zero && !overflow && (x % y != 0); |
| 1083 __ Move(r11, Smi::FromInt(x)); | 1118 __ Move(r11, Smi::FromInt(x)); |
| 1084 __ Move(r12, Smi::FromInt(y)); | 1119 __ Move(r14, Smi::FromInt(y)); |
| 1085 if (!fraction && !overflow && !negative_zero && !division_by_zero) { | 1120 if (!fraction && !overflow && !negative_zero && !division_by_zero) { |
| 1086 // Division succeeds | 1121 // Division succeeds |
| 1087 __ movq(rcx, r11); | 1122 __ movq(rcx, r11); |
| 1088 __ movq(r15, Immediate(id)); | 1123 __ movq(r12, Immediate(id)); |
| 1089 int result = x / y; | 1124 int result = x / y; |
| 1090 __ Move(r8, Smi::FromInt(result)); | 1125 __ Move(r8, Smi::FromInt(result)); |
| 1091 __ SmiDiv(r9, rcx, r12, exit); | 1126 __ SmiDiv(r9, rcx, r14, exit); |
| 1092 // Might have destroyed rcx and r12. | 1127 // Might have destroyed rcx and r14. |
| 1093 __ incq(r15); | 1128 __ incq(r12); |
| 1094 __ SmiCompare(r9, r8); | 1129 __ SmiCompare(r9, r8); |
| 1095 __ j(not_equal, exit); | 1130 __ j(not_equal, exit); |
| 1096 | 1131 |
| 1097 __ incq(r15); | 1132 __ incq(r12); |
| 1098 __ movq(rcx, r11); | 1133 __ movq(rcx, r11); |
| 1099 __ Move(r12, Smi::FromInt(y)); | 1134 __ Move(r14, Smi::FromInt(y)); |
| 1100 __ SmiCompare(rcx, r11); | 1135 __ SmiCompare(rcx, r11); |
| 1101 __ j(not_equal, exit); | 1136 __ j(not_equal, exit); |
| 1102 | 1137 |
| 1103 __ incq(r15); | 1138 __ incq(r12); |
| 1104 __ SmiDiv(rcx, rcx, r12, exit); | 1139 __ SmiDiv(rcx, rcx, r14, exit); |
| 1105 | 1140 |
| 1106 __ incq(r15); | 1141 __ incq(r12); |
| 1107 __ SmiCompare(rcx, r8); | 1142 __ SmiCompare(rcx, r8); |
| 1108 __ j(not_equal, exit); | 1143 __ j(not_equal, exit); |
| 1109 } else { | 1144 } else { |
| 1110 // Division fails. | 1145 // Division fails. |
| 1111 __ movq(r15, Immediate(id + 8)); | 1146 __ movq(r12, Immediate(id + 8)); |
| 1112 | 1147 |
| 1113 Label fail_ok, fail_ok2; | 1148 Label fail_ok, fail_ok2; |
| 1114 __ movq(rcx, r11); | 1149 __ movq(rcx, r11); |
| 1115 __ SmiDiv(r9, rcx, r12, &fail_ok); | 1150 __ SmiDiv(r9, rcx, r14, &fail_ok); |
| 1116 __ jmp(exit); | 1151 __ jmp(exit); |
| 1117 __ bind(&fail_ok); | 1152 __ bind(&fail_ok); |
| 1118 | 1153 |
| 1119 __ incq(r15); | 1154 __ incq(r12); |
| 1120 __ SmiCompare(rcx, r11); | 1155 __ SmiCompare(rcx, r11); |
| 1121 __ j(not_equal, exit); | 1156 __ j(not_equal, exit); |
| 1122 | 1157 |
| 1123 __ incq(r15); | 1158 __ incq(r12); |
| 1124 __ SmiDiv(rcx, rcx, r12, &fail_ok2); | 1159 __ SmiDiv(rcx, rcx, r14, &fail_ok2); |
| 1125 __ jmp(exit); | 1160 __ jmp(exit); |
| 1126 __ bind(&fail_ok2); | 1161 __ bind(&fail_ok2); |
| 1127 | 1162 |
| 1128 __ incq(r15); | 1163 __ incq(r12); |
| 1129 __ SmiCompare(rcx, r11); | 1164 __ SmiCompare(rcx, r11); |
| 1130 __ j(not_equal, exit); | 1165 __ j(not_equal, exit); |
| 1131 } | 1166 } |
| 1132 } | 1167 } |
| 1133 | 1168 |
| 1134 | 1169 |
| 1135 TEST(SmiDiv) { | 1170 TEST(SmiDiv) { |
| 1136 // Allocate an executable page of memory. | 1171 // Allocate an executable page of memory. |
| 1137 size_t actual_size; | 1172 size_t actual_size; |
| 1138 byte* buffer = | 1173 byte* buffer = |
| 1139 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1174 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1140 &actual_size, | 1175 &actual_size, |
| 1141 true)); | 1176 true)); |
| 1142 CHECK(buffer); | 1177 CHECK(buffer); |
| 1143 HandleScope handles; | 1178 HandleScope handles; |
| 1144 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1179 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1145 | 1180 |
| 1146 MacroAssembler* masm = &assembler; | 1181 MacroAssembler* masm = &assembler; |
| 1147 masm->set_allow_stub_calls(false); | 1182 masm->set_allow_stub_calls(false); |
| 1183 EntryCode(masm); |
| 1148 Label exit; | 1184 Label exit; |
| 1149 | 1185 |
| 1186 __ push(r14); |
| 1150 __ push(r12); | 1187 __ push(r12); |
| 1151 __ push(r15); | |
| 1152 TestSmiDiv(masm, &exit, 0x10, 1, 1); | 1188 TestSmiDiv(masm, &exit, 0x10, 1, 1); |
| 1153 TestSmiDiv(masm, &exit, 0x20, 1, 0); | 1189 TestSmiDiv(masm, &exit, 0x20, 1, 0); |
| 1154 TestSmiDiv(masm, &exit, 0x30, -1, 0); | 1190 TestSmiDiv(masm, &exit, 0x30, -1, 0); |
| 1155 TestSmiDiv(masm, &exit, 0x40, 0, 1); | 1191 TestSmiDiv(masm, &exit, 0x40, 0, 1); |
| 1156 TestSmiDiv(masm, &exit, 0x50, 0, -1); | 1192 TestSmiDiv(masm, &exit, 0x50, 0, -1); |
| 1157 TestSmiDiv(masm, &exit, 0x60, 4, 2); | 1193 TestSmiDiv(masm, &exit, 0x60, 4, 2); |
| 1158 TestSmiDiv(masm, &exit, 0x70, -4, 2); | 1194 TestSmiDiv(masm, &exit, 0x70, -4, 2); |
| 1159 TestSmiDiv(masm, &exit, 0x80, 4, -2); | 1195 TestSmiDiv(masm, &exit, 0x80, 4, -2); |
| 1160 TestSmiDiv(masm, &exit, 0x90, -4, -2); | 1196 TestSmiDiv(masm, &exit, 0x90, -4, -2); |
| 1161 TestSmiDiv(masm, &exit, 0xa0, 3, 2); | 1197 TestSmiDiv(masm, &exit, 0xa0, 3, 2); |
| 1162 TestSmiDiv(masm, &exit, 0xb0, 3, 4); | 1198 TestSmiDiv(masm, &exit, 0xb0, 3, 4); |
| 1163 TestSmiDiv(masm, &exit, 0xc0, 1, Smi::kMaxValue); | 1199 TestSmiDiv(masm, &exit, 0xc0, 1, Smi::kMaxValue); |
| 1164 TestSmiDiv(masm, &exit, 0xd0, -1, Smi::kMaxValue); | 1200 TestSmiDiv(masm, &exit, 0xd0, -1, Smi::kMaxValue); |
| 1165 TestSmiDiv(masm, &exit, 0xe0, Smi::kMaxValue, 1); | 1201 TestSmiDiv(masm, &exit, 0xe0, Smi::kMaxValue, 1); |
| 1166 TestSmiDiv(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue); | 1202 TestSmiDiv(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue); |
| 1167 TestSmiDiv(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue); | 1203 TestSmiDiv(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue); |
| 1168 TestSmiDiv(masm, &exit, 0x110, Smi::kMaxValue, -1); | 1204 TestSmiDiv(masm, &exit, 0x110, Smi::kMaxValue, -1); |
| 1169 TestSmiDiv(masm, &exit, 0x120, Smi::kMinValue, 1); | 1205 TestSmiDiv(masm, &exit, 0x120, Smi::kMinValue, 1); |
| 1170 TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue); | 1206 TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue); |
| 1171 TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1); | 1207 TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1); |
| 1172 | 1208 |
| 1173 __ xor_(r15, r15); // Success. | 1209 __ xor_(r12, r12); // Success. |
| 1174 __ bind(&exit); | 1210 __ bind(&exit); |
| 1175 __ movq(rax, r15); | 1211 __ movq(rax, r12); |
| 1176 __ pop(r15); | |
| 1177 __ pop(r12); | 1212 __ pop(r12); |
| 1213 __ pop(r14); |
| 1214 ExitCode(masm); |
| 1178 __ ret(0); | 1215 __ ret(0); |
| 1179 | 1216 |
| 1180 CodeDesc desc; | 1217 CodeDesc desc; |
| 1181 masm->GetCode(&desc); | 1218 masm->GetCode(&desc); |
| 1182 // Call the function from C++. | 1219 // Call the function from C++. |
| 1183 int result = FUNCTION_CAST<F0>(buffer)(); | 1220 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1184 CHECK_EQ(0, result); | 1221 CHECK_EQ(0, result); |
| 1185 } | 1222 } |
| 1186 | 1223 |
| 1187 | 1224 |
| 1188 void TestSmiMod(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1225 void TestSmiMod(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1189 bool division_by_zero = (y == 0); | 1226 bool division_by_zero = (y == 0); |
| 1190 bool division_overflow = (x == Smi::kMinValue) && (y == -1); | 1227 bool division_overflow = (x == Smi::kMinValue) && (y == -1); |
| 1191 bool fraction = !division_by_zero && !division_overflow && ((x % y) != 0); | 1228 bool fraction = !division_by_zero && !division_overflow && ((x % y) != 0); |
| 1192 bool negative_zero = (!fraction && x < 0); | 1229 bool negative_zero = (!fraction && x < 0); |
| 1193 __ Move(rcx, Smi::FromInt(x)); | 1230 __ Move(rcx, Smi::FromInt(x)); |
| 1194 __ movq(r11, rcx); | 1231 __ movq(r11, rcx); |
| 1195 __ Move(r12, Smi::FromInt(y)); | 1232 __ Move(r14, Smi::FromInt(y)); |
| 1196 if (!division_overflow && !negative_zero && !division_by_zero) { | 1233 if (!division_overflow && !negative_zero && !division_by_zero) { |
| 1197 // Modulo succeeds | 1234 // Modulo succeeds |
| 1198 __ movq(r15, Immediate(id)); | 1235 __ movq(r12, Immediate(id)); |
| 1199 int result = x % y; | 1236 int result = x % y; |
| 1200 __ Move(r8, Smi::FromInt(result)); | 1237 __ Move(r8, Smi::FromInt(result)); |
| 1201 __ SmiMod(r9, rcx, r12, exit); | 1238 __ SmiMod(r9, rcx, r14, exit); |
| 1202 | 1239 |
| 1203 __ incq(r15); | 1240 __ incq(r12); |
| 1204 __ SmiCompare(r9, r8); | 1241 __ SmiCompare(r9, r8); |
| 1205 __ j(not_equal, exit); | 1242 __ j(not_equal, exit); |
| 1206 | 1243 |
| 1207 __ incq(r15); | 1244 __ incq(r12); |
| 1208 __ SmiCompare(rcx, r11); | 1245 __ SmiCompare(rcx, r11); |
| 1209 __ j(not_equal, exit); | 1246 __ j(not_equal, exit); |
| 1210 | 1247 |
| 1211 __ incq(r15); | 1248 __ incq(r12); |
| 1212 __ SmiMod(rcx, rcx, r12, exit); | 1249 __ SmiMod(rcx, rcx, r14, exit); |
| 1213 | 1250 |
| 1214 __ incq(r15); | 1251 __ incq(r12); |
| 1215 __ SmiCompare(rcx, r8); | 1252 __ SmiCompare(rcx, r8); |
| 1216 __ j(not_equal, exit); | 1253 __ j(not_equal, exit); |
| 1217 } else { | 1254 } else { |
| 1218 // Modulo fails. | 1255 // Modulo fails. |
| 1219 __ movq(r15, Immediate(id + 8)); | 1256 __ movq(r12, Immediate(id + 8)); |
| 1220 | 1257 |
| 1221 Label fail_ok, fail_ok2; | 1258 Label fail_ok, fail_ok2; |
| 1222 __ SmiMod(r9, rcx, r12, &fail_ok); | 1259 __ SmiMod(r9, rcx, r14, &fail_ok); |
| 1223 __ jmp(exit); | 1260 __ jmp(exit); |
| 1224 __ bind(&fail_ok); | 1261 __ bind(&fail_ok); |
| 1225 | 1262 |
| 1226 __ incq(r15); | 1263 __ incq(r12); |
| 1227 __ SmiCompare(rcx, r11); | 1264 __ SmiCompare(rcx, r11); |
| 1228 __ j(not_equal, exit); | 1265 __ j(not_equal, exit); |
| 1229 | 1266 |
| 1230 __ incq(r15); | 1267 __ incq(r12); |
| 1231 __ SmiMod(rcx, rcx, r12, &fail_ok2); | 1268 __ SmiMod(rcx, rcx, r14, &fail_ok2); |
| 1232 __ jmp(exit); | 1269 __ jmp(exit); |
| 1233 __ bind(&fail_ok2); | 1270 __ bind(&fail_ok2); |
| 1234 | 1271 |
| 1235 __ incq(r15); | 1272 __ incq(r12); |
| 1236 __ SmiCompare(rcx, r11); | 1273 __ SmiCompare(rcx, r11); |
| 1237 __ j(not_equal, exit); | 1274 __ j(not_equal, exit); |
| 1238 } | 1275 } |
| 1239 } | 1276 } |
| 1240 | 1277 |
| 1241 | 1278 |
| 1242 TEST(SmiMod) { | 1279 TEST(SmiMod) { |
| 1243 // Allocate an executable page of memory. | 1280 // Allocate an executable page of memory. |
| 1244 size_t actual_size; | 1281 size_t actual_size; |
| 1245 byte* buffer = | 1282 byte* buffer = |
| 1246 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1283 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1247 &actual_size, | 1284 &actual_size, |
| 1248 true)); | 1285 true)); |
| 1249 CHECK(buffer); | 1286 CHECK(buffer); |
| 1250 HandleScope handles; | 1287 HandleScope handles; |
| 1251 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1288 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1252 | 1289 |
| 1253 MacroAssembler* masm = &assembler; | 1290 MacroAssembler* masm = &assembler; |
| 1254 masm->set_allow_stub_calls(false); | 1291 masm->set_allow_stub_calls(false); |
| 1292 EntryCode(masm); |
| 1255 Label exit; | 1293 Label exit; |
| 1256 | 1294 |
| 1295 __ push(r14); |
| 1257 __ push(r12); | 1296 __ push(r12); |
| 1258 __ push(r15); | |
| 1259 TestSmiMod(masm, &exit, 0x10, 1, 1); | 1297 TestSmiMod(masm, &exit, 0x10, 1, 1); |
| 1260 TestSmiMod(masm, &exit, 0x20, 1, 0); | 1298 TestSmiMod(masm, &exit, 0x20, 1, 0); |
| 1261 TestSmiMod(masm, &exit, 0x30, -1, 0); | 1299 TestSmiMod(masm, &exit, 0x30, -1, 0); |
| 1262 TestSmiMod(masm, &exit, 0x40, 0, 1); | 1300 TestSmiMod(masm, &exit, 0x40, 0, 1); |
| 1263 TestSmiMod(masm, &exit, 0x50, 0, -1); | 1301 TestSmiMod(masm, &exit, 0x50, 0, -1); |
| 1264 TestSmiMod(masm, &exit, 0x60, 4, 2); | 1302 TestSmiMod(masm, &exit, 0x60, 4, 2); |
| 1265 TestSmiMod(masm, &exit, 0x70, -4, 2); | 1303 TestSmiMod(masm, &exit, 0x70, -4, 2); |
| 1266 TestSmiMod(masm, &exit, 0x80, 4, -2); | 1304 TestSmiMod(masm, &exit, 0x80, 4, -2); |
| 1267 TestSmiMod(masm, &exit, 0x90, -4, -2); | 1305 TestSmiMod(masm, &exit, 0x90, -4, -2); |
| 1268 TestSmiMod(masm, &exit, 0xa0, 3, 2); | 1306 TestSmiMod(masm, &exit, 0xa0, 3, 2); |
| 1269 TestSmiMod(masm, &exit, 0xb0, 3, 4); | 1307 TestSmiMod(masm, &exit, 0xb0, 3, 4); |
| 1270 TestSmiMod(masm, &exit, 0xc0, 1, Smi::kMaxValue); | 1308 TestSmiMod(masm, &exit, 0xc0, 1, Smi::kMaxValue); |
| 1271 TestSmiMod(masm, &exit, 0xd0, -1, Smi::kMaxValue); | 1309 TestSmiMod(masm, &exit, 0xd0, -1, Smi::kMaxValue); |
| 1272 TestSmiMod(masm, &exit, 0xe0, Smi::kMaxValue, 1); | 1310 TestSmiMod(masm, &exit, 0xe0, Smi::kMaxValue, 1); |
| 1273 TestSmiMod(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue); | 1311 TestSmiMod(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue); |
| 1274 TestSmiMod(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue); | 1312 TestSmiMod(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue); |
| 1275 TestSmiMod(masm, &exit, 0x110, Smi::kMaxValue, -1); | 1313 TestSmiMod(masm, &exit, 0x110, Smi::kMaxValue, -1); |
| 1276 TestSmiMod(masm, &exit, 0x120, Smi::kMinValue, 1); | 1314 TestSmiMod(masm, &exit, 0x120, Smi::kMinValue, 1); |
| 1277 TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue); | 1315 TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue); |
| 1278 TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1); | 1316 TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1); |
| 1279 | 1317 |
| 1280 __ xor_(r15, r15); // Success. | 1318 __ xor_(r12, r12); // Success. |
| 1281 __ bind(&exit); | 1319 __ bind(&exit); |
| 1282 __ movq(rax, r15); | 1320 __ movq(rax, r12); |
| 1283 __ pop(r15); | |
| 1284 __ pop(r12); | 1321 __ pop(r12); |
| 1322 __ pop(r14); |
| 1323 ExitCode(masm); |
| 1285 __ ret(0); | 1324 __ ret(0); |
| 1286 | 1325 |
| 1287 CodeDesc desc; | 1326 CodeDesc desc; |
| 1288 masm->GetCode(&desc); | 1327 masm->GetCode(&desc); |
| 1289 // Call the function from C++. | 1328 // Call the function from C++. |
| 1290 int result = FUNCTION_CAST<F0>(buffer)(); | 1329 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1291 CHECK_EQ(0, result); | 1330 CHECK_EQ(0, result); |
| 1292 } | 1331 } |
| 1293 | 1332 |
| 1294 | 1333 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 __ SmiCompare(rcx, r8); | 1368 __ SmiCompare(rcx, r8); |
| 1330 __ j(not_equal, exit); | 1369 __ j(not_equal, exit); |
| 1331 __ incq(rax); | 1370 __ incq(rax); |
| 1332 } | 1371 } |
| 1333 } | 1372 } |
| 1334 | 1373 |
| 1335 TEST(SmiIndex) { | 1374 TEST(SmiIndex) { |
| 1336 // Allocate an executable page of memory. | 1375 // Allocate an executable page of memory. |
| 1337 size_t actual_size; | 1376 size_t actual_size; |
| 1338 byte* buffer = | 1377 byte* buffer = |
| 1339 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1378 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 1340 &actual_size, | 1379 &actual_size, |
| 1341 true)); | 1380 true)); |
| 1342 CHECK(buffer); | 1381 CHECK(buffer); |
| 1343 HandleScope handles; | 1382 HandleScope handles; |
| 1344 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1383 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1345 | 1384 |
| 1346 MacroAssembler* masm = &assembler; | 1385 MacroAssembler* masm = &assembler; |
| 1347 masm->set_allow_stub_calls(false); | 1386 masm->set_allow_stub_calls(false); |
| 1387 EntryCode(masm); |
| 1348 Label exit; | 1388 Label exit; |
| 1349 | 1389 |
| 1350 TestSmiIndex(masm, &exit, 0x10, 0); | 1390 TestSmiIndex(masm, &exit, 0x10, 0); |
| 1351 TestSmiIndex(masm, &exit, 0x20, 1); | 1391 TestSmiIndex(masm, &exit, 0x20, 1); |
| 1352 TestSmiIndex(masm, &exit, 0x30, 100); | 1392 TestSmiIndex(masm, &exit, 0x30, 100); |
| 1353 TestSmiIndex(masm, &exit, 0x40, 1000); | 1393 TestSmiIndex(masm, &exit, 0x40, 1000); |
| 1354 TestSmiIndex(masm, &exit, 0x50, Smi::kMaxValue); | 1394 TestSmiIndex(masm, &exit, 0x50, Smi::kMaxValue); |
| 1355 | 1395 |
| 1356 __ xor_(rax, rax); // Success. | 1396 __ xor_(rax, rax); // Success. |
| 1357 __ bind(&exit); | 1397 __ bind(&exit); |
| 1398 ExitCode(masm); |
| 1358 __ ret(0); | 1399 __ ret(0); |
| 1359 | 1400 |
| 1360 CodeDesc desc; | 1401 CodeDesc desc; |
| 1361 masm->GetCode(&desc); | 1402 masm->GetCode(&desc); |
| 1362 // Call the function from C++. | 1403 // Call the function from C++. |
| 1363 int result = FUNCTION_CAST<F0>(buffer)(); | 1404 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1364 CHECK_EQ(0, result); | 1405 CHECK_EQ(0, result); |
| 1365 } | 1406 } |
| 1366 | 1407 |
| 1367 | 1408 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 byte* buffer = | 1445 byte* buffer = |
| 1405 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1446 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1406 &actual_size, | 1447 &actual_size, |
| 1407 true)); | 1448 true)); |
| 1408 CHECK(buffer); | 1449 CHECK(buffer); |
| 1409 HandleScope handles; | 1450 HandleScope handles; |
| 1410 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1451 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1411 | 1452 |
| 1412 MacroAssembler* masm = &assembler; | 1453 MacroAssembler* masm = &assembler; |
| 1413 masm->set_allow_stub_calls(false); // Avoid inline checks. | 1454 masm->set_allow_stub_calls(false); // Avoid inline checks. |
| 1455 EntryCode(masm); |
| 1414 Label exit; | 1456 Label exit; |
| 1415 | 1457 |
| 1416 TestSelectNonSmi(masm, &exit, 0x10, 0, 0); | 1458 TestSelectNonSmi(masm, &exit, 0x10, 0, 0); |
| 1417 TestSelectNonSmi(masm, &exit, 0x20, 0, 1); | 1459 TestSelectNonSmi(masm, &exit, 0x20, 0, 1); |
| 1418 TestSelectNonSmi(masm, &exit, 0x30, 1, 0); | 1460 TestSelectNonSmi(masm, &exit, 0x30, 1, 0); |
| 1419 TestSelectNonSmi(masm, &exit, 0x40, 0, -1); | 1461 TestSelectNonSmi(masm, &exit, 0x40, 0, -1); |
| 1420 TestSelectNonSmi(masm, &exit, 0x50, -1, 0); | 1462 TestSelectNonSmi(masm, &exit, 0x50, -1, 0); |
| 1421 TestSelectNonSmi(masm, &exit, 0x60, -1, -1); | 1463 TestSelectNonSmi(masm, &exit, 0x60, -1, -1); |
| 1422 TestSelectNonSmi(masm, &exit, 0x70, 1, 1); | 1464 TestSelectNonSmi(masm, &exit, 0x70, 1, 1); |
| 1423 TestSelectNonSmi(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); | 1465 TestSelectNonSmi(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); |
| 1424 TestSelectNonSmi(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); | 1466 TestSelectNonSmi(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); |
| 1425 | 1467 |
| 1426 __ xor_(rax, rax); // Success. | 1468 __ xor_(rax, rax); // Success. |
| 1427 __ bind(&exit); | 1469 __ bind(&exit); |
| 1470 ExitCode(masm); |
| 1428 __ ret(0); | 1471 __ ret(0); |
| 1429 | 1472 |
| 1430 CodeDesc desc; | 1473 CodeDesc desc; |
| 1431 masm->GetCode(&desc); | 1474 masm->GetCode(&desc); |
| 1432 // Call the function from C++. | 1475 // Call the function from C++. |
| 1433 int result = FUNCTION_CAST<F0>(buffer)(); | 1476 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1434 CHECK_EQ(0, result); | 1477 CHECK_EQ(0, result); |
| 1435 } | 1478 } |
| 1436 | 1479 |
| 1437 | 1480 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 byte* buffer = | 1523 byte* buffer = |
| 1481 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1524 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1482 &actual_size, | 1525 &actual_size, |
| 1483 true)); | 1526 true)); |
| 1484 CHECK(buffer); | 1527 CHECK(buffer); |
| 1485 HandleScope handles; | 1528 HandleScope handles; |
| 1486 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1529 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1487 | 1530 |
| 1488 MacroAssembler* masm = &assembler; | 1531 MacroAssembler* masm = &assembler; |
| 1489 masm->set_allow_stub_calls(false); | 1532 masm->set_allow_stub_calls(false); |
| 1533 EntryCode(masm); |
| 1490 Label exit; | 1534 Label exit; |
| 1491 | 1535 |
| 1492 TestSmiAnd(masm, &exit, 0x10, 0, 0); | 1536 TestSmiAnd(masm, &exit, 0x10, 0, 0); |
| 1493 TestSmiAnd(masm, &exit, 0x20, 0, 1); | 1537 TestSmiAnd(masm, &exit, 0x20, 0, 1); |
| 1494 TestSmiAnd(masm, &exit, 0x30, 1, 0); | 1538 TestSmiAnd(masm, &exit, 0x30, 1, 0); |
| 1495 TestSmiAnd(masm, &exit, 0x40, 0, -1); | 1539 TestSmiAnd(masm, &exit, 0x40, 0, -1); |
| 1496 TestSmiAnd(masm, &exit, 0x50, -1, 0); | 1540 TestSmiAnd(masm, &exit, 0x50, -1, 0); |
| 1497 TestSmiAnd(masm, &exit, 0x60, -1, -1); | 1541 TestSmiAnd(masm, &exit, 0x60, -1, -1); |
| 1498 TestSmiAnd(masm, &exit, 0x70, 1, 1); | 1542 TestSmiAnd(masm, &exit, 0x70, 1, 1); |
| 1499 TestSmiAnd(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); | 1543 TestSmiAnd(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); |
| 1500 TestSmiAnd(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); | 1544 TestSmiAnd(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); |
| 1501 TestSmiAnd(masm, &exit, 0xA0, Smi::kMinValue, -1); | 1545 TestSmiAnd(masm, &exit, 0xA0, Smi::kMinValue, -1); |
| 1502 TestSmiAnd(masm, &exit, 0xB0, Smi::kMinValue, -1); | 1546 TestSmiAnd(masm, &exit, 0xB0, Smi::kMinValue, -1); |
| 1503 | 1547 |
| 1504 __ xor_(rax, rax); // Success. | 1548 __ xor_(rax, rax); // Success. |
| 1505 __ bind(&exit); | 1549 __ bind(&exit); |
| 1550 ExitCode(masm); |
| 1506 __ ret(0); | 1551 __ ret(0); |
| 1507 | 1552 |
| 1508 CodeDesc desc; | 1553 CodeDesc desc; |
| 1509 masm->GetCode(&desc); | 1554 masm->GetCode(&desc); |
| 1510 // Call the function from C++. | 1555 // Call the function from C++. |
| 1511 int result = FUNCTION_CAST<F0>(buffer)(); | 1556 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1512 CHECK_EQ(0, result); | 1557 CHECK_EQ(0, result); |
| 1513 } | 1558 } |
| 1514 | 1559 |
| 1515 | 1560 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 byte* buffer = | 1603 byte* buffer = |
| 1559 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1604 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1560 &actual_size, | 1605 &actual_size, |
| 1561 true)); | 1606 true)); |
| 1562 CHECK(buffer); | 1607 CHECK(buffer); |
| 1563 HandleScope handles; | 1608 HandleScope handles; |
| 1564 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1609 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1565 | 1610 |
| 1566 MacroAssembler* masm = &assembler; | 1611 MacroAssembler* masm = &assembler; |
| 1567 masm->set_allow_stub_calls(false); | 1612 masm->set_allow_stub_calls(false); |
| 1613 EntryCode(masm); |
| 1568 Label exit; | 1614 Label exit; |
| 1569 | 1615 |
| 1570 TestSmiOr(masm, &exit, 0x10, 0, 0); | 1616 TestSmiOr(masm, &exit, 0x10, 0, 0); |
| 1571 TestSmiOr(masm, &exit, 0x20, 0, 1); | 1617 TestSmiOr(masm, &exit, 0x20, 0, 1); |
| 1572 TestSmiOr(masm, &exit, 0x30, 1, 0); | 1618 TestSmiOr(masm, &exit, 0x30, 1, 0); |
| 1573 TestSmiOr(masm, &exit, 0x40, 0, -1); | 1619 TestSmiOr(masm, &exit, 0x40, 0, -1); |
| 1574 TestSmiOr(masm, &exit, 0x50, -1, 0); | 1620 TestSmiOr(masm, &exit, 0x50, -1, 0); |
| 1575 TestSmiOr(masm, &exit, 0x60, -1, -1); | 1621 TestSmiOr(masm, &exit, 0x60, -1, -1); |
| 1576 TestSmiOr(masm, &exit, 0x70, 1, 1); | 1622 TestSmiOr(masm, &exit, 0x70, 1, 1); |
| 1577 TestSmiOr(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); | 1623 TestSmiOr(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); |
| 1578 TestSmiOr(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); | 1624 TestSmiOr(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); |
| 1579 TestSmiOr(masm, &exit, 0xA0, Smi::kMinValue, -1); | 1625 TestSmiOr(masm, &exit, 0xA0, Smi::kMinValue, -1); |
| 1580 TestSmiOr(masm, &exit, 0xB0, 0x05555555, 0x01234567); | 1626 TestSmiOr(masm, &exit, 0xB0, 0x05555555, 0x01234567); |
| 1581 TestSmiOr(masm, &exit, 0xC0, 0x05555555, 0x0fedcba9); | 1627 TestSmiOr(masm, &exit, 0xC0, 0x05555555, 0x0fedcba9); |
| 1582 TestSmiOr(masm, &exit, 0xD0, Smi::kMinValue, -1); | 1628 TestSmiOr(masm, &exit, 0xD0, Smi::kMinValue, -1); |
| 1583 | 1629 |
| 1584 __ xor_(rax, rax); // Success. | 1630 __ xor_(rax, rax); // Success. |
| 1585 __ bind(&exit); | 1631 __ bind(&exit); |
| 1632 ExitCode(masm); |
| 1586 __ ret(0); | 1633 __ ret(0); |
| 1587 | 1634 |
| 1588 CodeDesc desc; | 1635 CodeDesc desc; |
| 1589 masm->GetCode(&desc); | 1636 masm->GetCode(&desc); |
| 1590 // Call the function from C++. | 1637 // Call the function from C++. |
| 1591 int result = FUNCTION_CAST<F0>(buffer)(); | 1638 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1592 CHECK_EQ(0, result); | 1639 CHECK_EQ(0, result); |
| 1593 } | 1640 } |
| 1594 | 1641 |
| 1595 | 1642 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 byte* buffer = | 1685 byte* buffer = |
| 1639 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1686 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1640 &actual_size, | 1687 &actual_size, |
| 1641 true)); | 1688 true)); |
| 1642 CHECK(buffer); | 1689 CHECK(buffer); |
| 1643 HandleScope handles; | 1690 HandleScope handles; |
| 1644 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1691 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1645 | 1692 |
| 1646 MacroAssembler* masm = &assembler; | 1693 MacroAssembler* masm = &assembler; |
| 1647 masm->set_allow_stub_calls(false); | 1694 masm->set_allow_stub_calls(false); |
| 1695 EntryCode(masm); |
| 1648 Label exit; | 1696 Label exit; |
| 1649 | 1697 |
| 1650 TestSmiXor(masm, &exit, 0x10, 0, 0); | 1698 TestSmiXor(masm, &exit, 0x10, 0, 0); |
| 1651 TestSmiXor(masm, &exit, 0x20, 0, 1); | 1699 TestSmiXor(masm, &exit, 0x20, 0, 1); |
| 1652 TestSmiXor(masm, &exit, 0x30, 1, 0); | 1700 TestSmiXor(masm, &exit, 0x30, 1, 0); |
| 1653 TestSmiXor(masm, &exit, 0x40, 0, -1); | 1701 TestSmiXor(masm, &exit, 0x40, 0, -1); |
| 1654 TestSmiXor(masm, &exit, 0x50, -1, 0); | 1702 TestSmiXor(masm, &exit, 0x50, -1, 0); |
| 1655 TestSmiXor(masm, &exit, 0x60, -1, -1); | 1703 TestSmiXor(masm, &exit, 0x60, -1, -1); |
| 1656 TestSmiXor(masm, &exit, 0x70, 1, 1); | 1704 TestSmiXor(masm, &exit, 0x70, 1, 1); |
| 1657 TestSmiXor(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); | 1705 TestSmiXor(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue); |
| 1658 TestSmiXor(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); | 1706 TestSmiXor(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue); |
| 1659 TestSmiXor(masm, &exit, 0xA0, Smi::kMinValue, -1); | 1707 TestSmiXor(masm, &exit, 0xA0, Smi::kMinValue, -1); |
| 1660 TestSmiXor(masm, &exit, 0xB0, 0x5555555, 0x01234567); | 1708 TestSmiXor(masm, &exit, 0xB0, 0x5555555, 0x01234567); |
| 1661 TestSmiXor(masm, &exit, 0xC0, 0x5555555, 0x0fedcba9); | 1709 TestSmiXor(masm, &exit, 0xC0, 0x5555555, 0x0fedcba9); |
| 1662 TestSmiXor(masm, &exit, 0xD0, Smi::kMinValue, -1); | 1710 TestSmiXor(masm, &exit, 0xD0, Smi::kMinValue, -1); |
| 1663 | 1711 |
| 1664 __ xor_(rax, rax); // Success. | 1712 __ xor_(rax, rax); // Success. |
| 1665 __ bind(&exit); | 1713 __ bind(&exit); |
| 1714 ExitCode(masm); |
| 1666 __ ret(0); | 1715 __ ret(0); |
| 1667 | 1716 |
| 1668 CodeDesc desc; | 1717 CodeDesc desc; |
| 1669 masm->GetCode(&desc); | 1718 masm->GetCode(&desc); |
| 1670 // Call the function from C++. | 1719 // Call the function from C++. |
| 1671 int result = FUNCTION_CAST<F0>(buffer)(); | 1720 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1672 CHECK_EQ(0, result); | 1721 CHECK_EQ(0, result); |
| 1673 } | 1722 } |
| 1674 | 1723 |
| 1675 | 1724 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1702 byte* buffer = | 1751 byte* buffer = |
| 1703 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1752 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1704 &actual_size, | 1753 &actual_size, |
| 1705 true)); | 1754 true)); |
| 1706 CHECK(buffer); | 1755 CHECK(buffer); |
| 1707 HandleScope handles; | 1756 HandleScope handles; |
| 1708 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1757 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1709 | 1758 |
| 1710 MacroAssembler* masm = &assembler; | 1759 MacroAssembler* masm = &assembler; |
| 1711 masm->set_allow_stub_calls(false); | 1760 masm->set_allow_stub_calls(false); |
| 1761 EntryCode(masm); |
| 1712 Label exit; | 1762 Label exit; |
| 1713 | 1763 |
| 1714 TestSmiNot(masm, &exit, 0x10, 0); | 1764 TestSmiNot(masm, &exit, 0x10, 0); |
| 1715 TestSmiNot(masm, &exit, 0x20, 1); | 1765 TestSmiNot(masm, &exit, 0x20, 1); |
| 1716 TestSmiNot(masm, &exit, 0x30, -1); | 1766 TestSmiNot(masm, &exit, 0x30, -1); |
| 1717 TestSmiNot(masm, &exit, 0x40, 127); | 1767 TestSmiNot(masm, &exit, 0x40, 127); |
| 1718 TestSmiNot(masm, &exit, 0x50, 65535); | 1768 TestSmiNot(masm, &exit, 0x50, 65535); |
| 1719 TestSmiNot(masm, &exit, 0x60, Smi::kMinValue); | 1769 TestSmiNot(masm, &exit, 0x60, Smi::kMinValue); |
| 1720 TestSmiNot(masm, &exit, 0x70, Smi::kMaxValue); | 1770 TestSmiNot(masm, &exit, 0x70, Smi::kMaxValue); |
| 1721 TestSmiNot(masm, &exit, 0x80, 0x05555555); | 1771 TestSmiNot(masm, &exit, 0x80, 0x05555555); |
| 1722 | 1772 |
| 1723 __ xor_(rax, rax); // Success. | 1773 __ xor_(rax, rax); // Success. |
| 1724 __ bind(&exit); | 1774 __ bind(&exit); |
| 1775 ExitCode(masm); |
| 1725 __ ret(0); | 1776 __ ret(0); |
| 1726 | 1777 |
| 1727 CodeDesc desc; | 1778 CodeDesc desc; |
| 1728 masm->GetCode(&desc); | 1779 masm->GetCode(&desc); |
| 1729 // Call the function from C++. | 1780 // Call the function from C++. |
| 1730 int result = FUNCTION_CAST<F0>(buffer)(); | 1781 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1731 CHECK_EQ(0, result); | 1782 CHECK_EQ(0, result); |
| 1732 } | 1783 } |
| 1733 | 1784 |
| 1734 | 1785 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 | 1837 |
| 1787 __ incq(rax); | 1838 __ incq(rax); |
| 1788 } | 1839 } |
| 1789 } | 1840 } |
| 1790 | 1841 |
| 1791 | 1842 |
| 1792 TEST(SmiShiftLeft) { | 1843 TEST(SmiShiftLeft) { |
| 1793 // Allocate an executable page of memory. | 1844 // Allocate an executable page of memory. |
| 1794 size_t actual_size; | 1845 size_t actual_size; |
| 1795 byte* buffer = | 1846 byte* buffer = |
| 1796 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 1847 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
| 1797 &actual_size, | 1848 &actual_size, |
| 1798 true)); | 1849 true)); |
| 1799 CHECK(buffer); | 1850 CHECK(buffer); |
| 1800 HandleScope handles; | 1851 HandleScope handles; |
| 1801 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1852 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1802 | 1853 |
| 1803 MacroAssembler* masm = &assembler; | 1854 MacroAssembler* masm = &assembler; |
| 1804 masm->set_allow_stub_calls(false); | 1855 masm->set_allow_stub_calls(false); |
| 1856 EntryCode(masm); |
| 1805 Label exit; | 1857 Label exit; |
| 1806 | 1858 |
| 1807 TestSmiShiftLeft(masm, &exit, 0x10, 0); | 1859 TestSmiShiftLeft(masm, &exit, 0x10, 0); |
| 1808 TestSmiShiftLeft(masm, &exit, 0x50, 1); | 1860 TestSmiShiftLeft(masm, &exit, 0x50, 1); |
| 1809 TestSmiShiftLeft(masm, &exit, 0x90, 127); | 1861 TestSmiShiftLeft(masm, &exit, 0x90, 127); |
| 1810 TestSmiShiftLeft(masm, &exit, 0xD0, 65535); | 1862 TestSmiShiftLeft(masm, &exit, 0xD0, 65535); |
| 1811 TestSmiShiftLeft(masm, &exit, 0x110, Smi::kMaxValue); | 1863 TestSmiShiftLeft(masm, &exit, 0x110, Smi::kMaxValue); |
| 1812 TestSmiShiftLeft(masm, &exit, 0x150, Smi::kMinValue); | 1864 TestSmiShiftLeft(masm, &exit, 0x150, Smi::kMinValue); |
| 1813 TestSmiShiftLeft(masm, &exit, 0x190, -1); | 1865 TestSmiShiftLeft(masm, &exit, 0x190, -1); |
| 1814 | 1866 |
| 1815 __ xor_(rax, rax); // Success. | 1867 __ xor_(rax, rax); // Success. |
| 1816 __ bind(&exit); | 1868 __ bind(&exit); |
| 1869 ExitCode(masm); |
| 1817 __ ret(0); | 1870 __ ret(0); |
| 1818 | 1871 |
| 1819 CodeDesc desc; | 1872 CodeDesc desc; |
| 1820 masm->GetCode(&desc); | 1873 masm->GetCode(&desc); |
| 1821 // Call the function from C++. | 1874 // Call the function from C++. |
| 1822 int result = FUNCTION_CAST<F0>(buffer)(); | 1875 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1823 CHECK_EQ(0, result); | 1876 CHECK_EQ(0, result); |
| 1824 } | 1877 } |
| 1825 | 1878 |
| 1826 | 1879 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 __ addq(rax, Immediate(3)); | 1942 __ addq(rax, Immediate(3)); |
| 1890 } | 1943 } |
| 1891 } | 1944 } |
| 1892 } | 1945 } |
| 1893 | 1946 |
| 1894 | 1947 |
| 1895 TEST(SmiShiftLogicalRight) { | 1948 TEST(SmiShiftLogicalRight) { |
| 1896 // Allocate an executable page of memory. | 1949 // Allocate an executable page of memory. |
| 1897 size_t actual_size; | 1950 size_t actual_size; |
| 1898 byte* buffer = | 1951 byte* buffer = |
| 1899 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1952 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 1900 &actual_size, | 1953 &actual_size, |
| 1901 true)); | 1954 true)); |
| 1902 CHECK(buffer); | 1955 CHECK(buffer); |
| 1903 HandleScope handles; | 1956 HandleScope handles; |
| 1904 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 1957 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1905 | 1958 |
| 1906 MacroAssembler* masm = &assembler; | 1959 MacroAssembler* masm = &assembler; |
| 1907 masm->set_allow_stub_calls(false); | 1960 masm->set_allow_stub_calls(false); |
| 1961 EntryCode(masm); |
| 1908 Label exit; | 1962 Label exit; |
| 1909 | 1963 |
| 1910 TestSmiShiftLogicalRight(masm, &exit, 0x10, 0); | 1964 TestSmiShiftLogicalRight(masm, &exit, 0x10, 0); |
| 1911 TestSmiShiftLogicalRight(masm, &exit, 0x30, 1); | 1965 TestSmiShiftLogicalRight(masm, &exit, 0x30, 1); |
| 1912 TestSmiShiftLogicalRight(masm, &exit, 0x50, 127); | 1966 TestSmiShiftLogicalRight(masm, &exit, 0x50, 127); |
| 1913 TestSmiShiftLogicalRight(masm, &exit, 0x70, 65535); | 1967 TestSmiShiftLogicalRight(masm, &exit, 0x70, 65535); |
| 1914 TestSmiShiftLogicalRight(masm, &exit, 0x90, Smi::kMaxValue); | 1968 TestSmiShiftLogicalRight(masm, &exit, 0x90, Smi::kMaxValue); |
| 1915 TestSmiShiftLogicalRight(masm, &exit, 0xB0, Smi::kMinValue); | 1969 TestSmiShiftLogicalRight(masm, &exit, 0xB0, Smi::kMinValue); |
| 1916 TestSmiShiftLogicalRight(masm, &exit, 0xD0, -1); | 1970 TestSmiShiftLogicalRight(masm, &exit, 0xD0, -1); |
| 1917 | 1971 |
| 1918 __ xor_(rax, rax); // Success. | 1972 __ xor_(rax, rax); // Success. |
| 1919 __ bind(&exit); | 1973 __ bind(&exit); |
| 1974 ExitCode(masm); |
| 1920 __ ret(0); | 1975 __ ret(0); |
| 1921 | 1976 |
| 1922 CodeDesc desc; | 1977 CodeDesc desc; |
| 1923 masm->GetCode(&desc); | 1978 masm->GetCode(&desc); |
| 1924 // Call the function from C++. | 1979 // Call the function from C++. |
| 1925 int result = FUNCTION_CAST<F0>(buffer)(); | 1980 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1926 CHECK_EQ(0, result); | 1981 CHECK_EQ(0, result); |
| 1927 } | 1982 } |
| 1928 | 1983 |
| 1929 | 1984 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 byte* buffer = | 2019 byte* buffer = |
| 1965 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2020 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1966 &actual_size, | 2021 &actual_size, |
| 1967 true)); | 2022 true)); |
| 1968 CHECK(buffer); | 2023 CHECK(buffer); |
| 1969 HandleScope handles; | 2024 HandleScope handles; |
| 1970 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 2025 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 1971 | 2026 |
| 1972 MacroAssembler* masm = &assembler; | 2027 MacroAssembler* masm = &assembler; |
| 1973 masm->set_allow_stub_calls(false); | 2028 masm->set_allow_stub_calls(false); |
| 2029 EntryCode(masm); |
| 1974 Label exit; | 2030 Label exit; |
| 1975 | 2031 |
| 1976 TestSmiShiftArithmeticRight(masm, &exit, 0x10, 0); | 2032 TestSmiShiftArithmeticRight(masm, &exit, 0x10, 0); |
| 1977 TestSmiShiftArithmeticRight(masm, &exit, 0x20, 1); | 2033 TestSmiShiftArithmeticRight(masm, &exit, 0x20, 1); |
| 1978 TestSmiShiftArithmeticRight(masm, &exit, 0x30, 127); | 2034 TestSmiShiftArithmeticRight(masm, &exit, 0x30, 127); |
| 1979 TestSmiShiftArithmeticRight(masm, &exit, 0x40, 65535); | 2035 TestSmiShiftArithmeticRight(masm, &exit, 0x40, 65535); |
| 1980 TestSmiShiftArithmeticRight(masm, &exit, 0x50, Smi::kMaxValue); | 2036 TestSmiShiftArithmeticRight(masm, &exit, 0x50, Smi::kMaxValue); |
| 1981 TestSmiShiftArithmeticRight(masm, &exit, 0x60, Smi::kMinValue); | 2037 TestSmiShiftArithmeticRight(masm, &exit, 0x60, Smi::kMinValue); |
| 1982 TestSmiShiftArithmeticRight(masm, &exit, 0x70, -1); | 2038 TestSmiShiftArithmeticRight(masm, &exit, 0x70, -1); |
| 1983 | 2039 |
| 1984 __ xor_(rax, rax); // Success. | 2040 __ xor_(rax, rax); // Success. |
| 1985 __ bind(&exit); | 2041 __ bind(&exit); |
| 2042 ExitCode(masm); |
| 1986 __ ret(0); | 2043 __ ret(0); |
| 1987 | 2044 |
| 1988 CodeDesc desc; | 2045 CodeDesc desc; |
| 1989 masm->GetCode(&desc); | 2046 masm->GetCode(&desc); |
| 1990 // Call the function from C++. | 2047 // Call the function from C++. |
| 1991 int result = FUNCTION_CAST<F0>(buffer)(); | 2048 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1992 CHECK_EQ(0, result); | 2049 CHECK_EQ(0, result); |
| 1993 } | 2050 } |
| 1994 | 2051 |
| 1995 | 2052 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2025 byte* buffer = | 2082 byte* buffer = |
| 2026 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2083 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 2027 &actual_size, | 2084 &actual_size, |
| 2028 true)); | 2085 true)); |
| 2029 CHECK(buffer); | 2086 CHECK(buffer); |
| 2030 HandleScope handles; | 2087 HandleScope handles; |
| 2031 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 2088 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 2032 | 2089 |
| 2033 MacroAssembler* masm = &assembler; | 2090 MacroAssembler* masm = &assembler; |
| 2034 masm->set_allow_stub_calls(false); | 2091 masm->set_allow_stub_calls(false); |
| 2092 EntryCode(masm); |
| 2035 Label exit; | 2093 Label exit; |
| 2036 | 2094 |
| 2037 TestPositiveSmiPowerUp(masm, &exit, 0x20, 0); | 2095 TestPositiveSmiPowerUp(masm, &exit, 0x20, 0); |
| 2038 TestPositiveSmiPowerUp(masm, &exit, 0x40, 1); | 2096 TestPositiveSmiPowerUp(masm, &exit, 0x40, 1); |
| 2039 TestPositiveSmiPowerUp(masm, &exit, 0x60, 127); | 2097 TestPositiveSmiPowerUp(masm, &exit, 0x60, 127); |
| 2040 TestPositiveSmiPowerUp(masm, &exit, 0x80, 128); | 2098 TestPositiveSmiPowerUp(masm, &exit, 0x80, 128); |
| 2041 TestPositiveSmiPowerUp(masm, &exit, 0xA0, 255); | 2099 TestPositiveSmiPowerUp(masm, &exit, 0xA0, 255); |
| 2042 TestPositiveSmiPowerUp(masm, &exit, 0xC0, 256); | 2100 TestPositiveSmiPowerUp(masm, &exit, 0xC0, 256); |
| 2043 TestPositiveSmiPowerUp(masm, &exit, 0x100, 65535); | 2101 TestPositiveSmiPowerUp(masm, &exit, 0x100, 65535); |
| 2044 TestPositiveSmiPowerUp(masm, &exit, 0x120, 65536); | 2102 TestPositiveSmiPowerUp(masm, &exit, 0x120, 65536); |
| 2045 TestPositiveSmiPowerUp(masm, &exit, 0x140, Smi::kMaxValue); | 2103 TestPositiveSmiPowerUp(masm, &exit, 0x140, Smi::kMaxValue); |
| 2046 | 2104 |
| 2047 __ xor_(rax, rax); // Success. | 2105 __ xor_(rax, rax); // Success. |
| 2048 __ bind(&exit); | 2106 __ bind(&exit); |
| 2107 ExitCode(masm); |
| 2049 __ ret(0); | 2108 __ ret(0); |
| 2050 | 2109 |
| 2051 CodeDesc desc; | 2110 CodeDesc desc; |
| 2052 masm->GetCode(&desc); | 2111 masm->GetCode(&desc); |
| 2053 // Call the function from C++. | 2112 // Call the function from C++. |
| 2054 int result = FUNCTION_CAST<F0>(buffer)(); | 2113 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2055 CHECK_EQ(0, result); | 2114 CHECK_EQ(0, result); |
| 2056 } | 2115 } |
| 2057 | 2116 |
| 2058 | 2117 |
| 2059 TEST(OperandOffset) { | 2118 TEST(OperandOffset) { |
| 2060 int data[256]; | 2119 int data[256]; |
| 2061 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } | 2120 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } |
| 2062 | 2121 |
| 2063 // Allocate an executable page of memory. | 2122 // Allocate an executable page of memory. |
| 2064 size_t actual_size; | 2123 size_t actual_size; |
| 2065 byte* buffer = | 2124 byte* buffer = |
| 2066 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2125 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 2067 &actual_size, | 2126 &actual_size, |
| 2068 true)); | 2127 true)); |
| 2069 CHECK(buffer); | 2128 CHECK(buffer); |
| 2070 HandleScope handles; | 2129 HandleScope handles; |
| 2071 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 2130 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 2072 | 2131 |
| 2073 MacroAssembler* masm = &assembler; | 2132 MacroAssembler* masm = &assembler; |
| 2074 masm->set_allow_stub_calls(false); | 2133 masm->set_allow_stub_calls(false); |
| 2075 Label exit; | 2134 Label exit; |
| 2076 | 2135 |
| 2077 __ push(r12); | 2136 EntryCode(masm); |
| 2078 __ push(r13); | 2137 __ push(r13); |
| 2138 __ push(r14); |
| 2079 __ push(rbx); | 2139 __ push(rbx); |
| 2080 __ push(rbp); | 2140 __ push(rbp); |
| 2081 __ push(Immediate(0x100)); // <-- rbp | 2141 __ push(Immediate(0x100)); // <-- rbp |
| 2082 __ movq(rbp, rsp); | 2142 __ movq(rbp, rsp); |
| 2083 __ push(Immediate(0x101)); | 2143 __ push(Immediate(0x101)); |
| 2084 __ push(Immediate(0x102)); | 2144 __ push(Immediate(0x102)); |
| 2085 __ push(Immediate(0x103)); | 2145 __ push(Immediate(0x103)); |
| 2086 __ push(Immediate(0x104)); | 2146 __ push(Immediate(0x104)); |
| 2087 __ push(Immediate(0x105)); // <-- rbx | 2147 __ push(Immediate(0x105)); // <-- rbx |
| 2088 __ push(Immediate(0x106)); | 2148 __ push(Immediate(0x106)); |
| 2089 __ push(Immediate(0x107)); | 2149 __ push(Immediate(0x107)); |
| 2090 __ push(Immediate(0x108)); | 2150 __ push(Immediate(0x108)); |
| 2091 __ push(Immediate(0x109)); // <-- rsp | 2151 __ push(Immediate(0x109)); // <-- rsp |
| 2092 // rbp = rsp[9] | 2152 // rbp = rsp[9] |
| 2093 // r12 = rsp[3] | 2153 // r12 = rsp[3] |
| 2094 // rbx = rsp[5] | 2154 // rbx = rsp[5] |
| 2095 // r13 = rsp[7] | 2155 // r13 = rsp[7] |
| 2096 __ lea(r12, Operand(rsp, 3 * kPointerSize)); | 2156 __ lea(r14, Operand(rsp, 3 * kPointerSize)); |
| 2097 __ lea(r13, Operand(rbp, -3 * kPointerSize)); | 2157 __ lea(r13, Operand(rbp, -3 * kPointerSize)); |
| 2098 __ lea(rbx, Operand(rbp, -5 * kPointerSize)); | 2158 __ lea(rbx, Operand(rbp, -5 * kPointerSize)); |
| 2099 __ movl(rcx, Immediate(2)); | 2159 __ movl(rcx, Immediate(2)); |
| 2100 __ movq(r8, reinterpret_cast<uintptr_t>(&data[128]), RelocInfo::NONE); | 2160 __ movq(r8, reinterpret_cast<uintptr_t>(&data[128]), RelocInfo::NONE); |
| 2101 __ movl(rax, Immediate(1)); | 2161 __ movl(rax, Immediate(1)); |
| 2102 | 2162 |
| 2103 Operand sp0 = Operand(rsp, 0); | 2163 Operand sp0 = Operand(rsp, 0); |
| 2104 | 2164 |
| 2105 // Test 1. | 2165 // Test 1. |
| 2106 __ movl(rdx, sp0); // Sanity check. | 2166 __ movl(rdx, sp0); // Sanity check. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2389 __ j(not_equal, &exit); | 2449 __ j(not_equal, &exit); |
| 2390 __ incq(rax); | 2450 __ incq(rax); |
| 2391 | 2451 |
| 2392 // Success. | 2452 // Success. |
| 2393 | 2453 |
| 2394 __ movl(rax, Immediate(0)); | 2454 __ movl(rax, Immediate(0)); |
| 2395 __ bind(&exit); | 2455 __ bind(&exit); |
| 2396 __ lea(rsp, Operand(rbp, kPointerSize)); | 2456 __ lea(rsp, Operand(rbp, kPointerSize)); |
| 2397 __ pop(rbp); | 2457 __ pop(rbp); |
| 2398 __ pop(rbx); | 2458 __ pop(rbx); |
| 2459 __ pop(r14); |
| 2399 __ pop(r13); | 2460 __ pop(r13); |
| 2400 __ pop(r12); | 2461 ExitCode(masm); |
| 2401 __ ret(0); | 2462 __ ret(0); |
| 2402 | 2463 |
| 2403 | 2464 |
| 2404 CodeDesc desc; | 2465 CodeDesc desc; |
| 2405 masm->GetCode(&desc); | 2466 masm->GetCode(&desc); |
| 2406 // Call the function from C++. | 2467 // Call the function from C++. |
| 2407 int result = FUNCTION_CAST<F0>(buffer)(); | 2468 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2408 CHECK_EQ(0, result); | 2469 CHECK_EQ(0, result); |
| 2409 } | 2470 } |
| 2410 | 2471 |
| 2411 | 2472 |
| 2412 | 2473 |
| 2413 #undef __ | 2474 #undef __ |
| OLD | NEW |