| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 24 matching lines...) Expand all Loading... |
| 35 #include "src/code-stubs.h" | 35 #include "src/code-stubs.h" |
| 36 #include "src/factory.h" | 36 #include "src/factory.h" |
| 37 #include "src/macro-assembler.h" | 37 #include "src/macro-assembler.h" |
| 38 #include "test/cctest/cctest.h" | 38 #include "test/cctest/cctest.h" |
| 39 #include "test/cctest/test-code-stubs.h" | 39 #include "test/cctest/test-code-stubs.h" |
| 40 | 40 |
| 41 using namespace v8::internal; | 41 using namespace v8::internal; |
| 42 | 42 |
| 43 | 43 |
| 44 int STDCALL ConvertDToICVersion(double d) { | 44 int STDCALL ConvertDToICVersion(double d) { |
| 45 #if defined(V8_TARGET_BIG_ENDIAN) |
| 46 const int kExponentIndex = 0; |
| 47 const int kMantissaIndex = 1; |
| 48 #elif defined(V8_TARGET_LITTLE_ENDIAN) |
| 49 const int kExponentIndex = 1; |
| 50 const int kMantissaIndex = 0; |
| 51 #else |
| 52 #error Unsupported endianness |
| 53 #endif |
| 45 union { double d; uint32_t u[2]; } dbl; | 54 union { double d; uint32_t u[2]; } dbl; |
| 46 dbl.d = d; | 55 dbl.d = d; |
| 47 uint32_t exponent_bits = dbl.u[1]; | 56 uint32_t exponent_bits = dbl.u[kExponentIndex]; |
| 48 int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32); | 57 int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32); |
| 49 int32_t exponent = (((exponent_bits & shifted_mask) >> | 58 int32_t exponent = (((exponent_bits & shifted_mask) >> |
| 50 (Double::kPhysicalSignificandSize - 32)) - | 59 (Double::kPhysicalSignificandSize - 32)) - |
| 51 HeapNumber::kExponentBias); | 60 HeapNumber::kExponentBias); |
| 52 if (exponent < 0) { | 61 if (exponent < 0) { |
| 53 return 0; | 62 return 0; |
| 54 } | 63 } |
| 55 uint32_t unsigned_exponent = static_cast<uint32_t>(exponent); | 64 uint32_t unsigned_exponent = static_cast<uint32_t>(exponent); |
| 56 int result = 0; | 65 int result = 0; |
| 57 uint32_t max_exponent = | 66 uint32_t max_exponent = |
| 58 static_cast<uint32_t>(Double::kPhysicalSignificandSize); | 67 static_cast<uint32_t>(Double::kPhysicalSignificandSize); |
| 59 if (unsigned_exponent >= max_exponent) { | 68 if (unsigned_exponent >= max_exponent) { |
| 60 if ((exponent - Double::kPhysicalSignificandSize) < 32) { | 69 if ((exponent - Double::kPhysicalSignificandSize) < 32) { |
| 61 result = dbl.u[0] << (exponent - Double::kPhysicalSignificandSize); | 70 result = dbl.u[kMantissaIndex] |
| 71 << (exponent - Double::kPhysicalSignificandSize); |
| 62 } | 72 } |
| 63 } else { | 73 } else { |
| 64 uint64_t big_result = | 74 uint64_t big_result = |
| 65 (bit_cast<uint64_t>(d) & Double::kSignificandMask) | Double::kHiddenBit; | 75 (bit_cast<uint64_t>(d) & Double::kSignificandMask) | Double::kHiddenBit; |
| 66 big_result = big_result >> (Double::kPhysicalSignificandSize - exponent); | 76 big_result = big_result >> (Double::kPhysicalSignificandSize - exponent); |
| 67 result = static_cast<uint32_t>(big_result); | 77 result = static_cast<uint32_t>(big_result); |
| 68 } | 78 } |
| 69 if (static_cast<int32_t>(exponent_bits) < 0) { | 79 if (static_cast<int32_t>(exponent_bits) < 0) { |
| 70 return (0 - result); | 80 return (0 - result); |
| 71 } else { | 81 } else { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 190 |
| 181 #define CHECK_STUB(NAME) \ | 191 #define CHECK_STUB(NAME) \ |
| 182 { \ | 192 { \ |
| 183 HandleScope scope(isolate); \ | 193 HandleScope scope(isolate); \ |
| 184 NAME##Stub stub_impl(0xabcd, isolate); \ | 194 NAME##Stub stub_impl(0xabcd, isolate); \ |
| 185 CodeStub* stub = &stub_impl; \ | 195 CodeStub* stub = &stub_impl; \ |
| 186 CHECK_EQ(stub->MajorKey(), CodeStub::NAME); \ | 196 CHECK_EQ(stub->MajorKey(), CodeStub::NAME); \ |
| 187 } | 197 } |
| 188 CODE_STUB_LIST(CHECK_STUB); | 198 CODE_STUB_LIST(CHECK_STUB); |
| 189 } | 199 } |
| OLD | NEW |