Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: test/cctest/test-code-stubs-ia32.cc

Issue 18915009: Fix windows build breakage due to 15645 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix missing header Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #include <limits>
31
30 #include "v8.h" 32 #include "v8.h"
31 33
32 #include "cctest.h" 34 #include "cctest.h"
33 #include "code-stubs.h" 35 #include "code-stubs.h"
34 #include "factory.h" 36 #include "factory.h"
35 #include "macro-assembler.h" 37 #include "macro-assembler.h"
36 #include "platform.h" 38 #include "platform.h"
37 39
38 #if __GNUC__ 40 #if __GNUC__
39 #define STDCALL __attribute__((stdcall)) 41 #define STDCALL __attribute__((stdcall))
40 #else 42 #else
41 #define STDCALL __stdcall 43 #define STDCALL __stdcall
42 #endif 44 #endif
43 45
44 using namespace v8::internal; 46 using namespace v8::internal;
45 47
46 48
47 typedef int32_t STDCALL (*ConvertDToIFunc)(double input); 49 typedef int32_t STDCALL ConvertDToIFuncType(double input);
50 typedef ConvertDToIFuncType* ConvertDToIFunc;
48 51
49 52
50 int STDCALL ConvertDToICVersion(double d) { 53 int STDCALL ConvertDToICVersion(double d) {
51 Address double_ptr = reinterpret_cast<Address>(&d); 54 Address double_ptr = reinterpret_cast<Address>(&d);
52 uint32_t exponent_bits = Memory::uint32_at(double_ptr + kDoubleSize / 2); 55 uint32_t exponent_bits = Memory::uint32_at(double_ptr + kDoubleSize / 2);
53 int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32); 56 int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32);
54 int32_t exponent = (((exponent_bits & shifted_mask) >> 57 int32_t exponent = (((exponent_bits & shifted_mask) >>
55 (Double::kPhysicalSignificandSize - 32)) - 58 (Double::kPhysicalSignificandSize - 32)) -
56 HeapNumber::kExponentBias); 59 HeapNumber::kExponentBias);
57 uint32_t unsigned_exponent = static_cast<uint32_t>(exponent); 60 uint32_t unsigned_exponent = static_cast<uint32_t>(exponent);
(...skipping 14 matching lines...) Expand all
72 if (static_cast<int32_t>(exponent_bits) < 0) { 75 if (static_cast<int32_t>(exponent_bits) < 0) {
73 return (0 - result); 76 return (0 - result);
74 } else { 77 } else {
75 return result; 78 return result;
76 } 79 }
77 } 80 }
78 81
79 82
80 void RunOneTruncationTestWithTest(ConvertDToIFunc func, 83 void RunOneTruncationTestWithTest(ConvertDToIFunc func,
81 double from, 84 double from,
82 int64_t to) { 85 double raw) {
86 uint64_t to = static_cast<int64_t>(raw);
83 int result = (*func)(from); 87 int result = (*func)(from);
84 CHECK_EQ(static_cast<int>(to), result); 88 CHECK_EQ(static_cast<int>(to), result);
85 } 89 }
86 90
87 91
88 // #define NaN and Infinity so that it's possible to cut-and-paste these tests 92 // #define NaN and Infinity so that it's possible to cut-and-paste these tests
89 // directly to a .js file and run them. 93 // directly to a .js file and run them.
90 #define NaN NAN 94 #define NaN (OS::nan_value())
91 #define Infinity INFINITY 95 #define Infinity (std::numeric_limits<double>::infinity())
92 #define RunOneTruncationTest(p1, p2) RunOneTruncationTestWithTest(func, p1, p2) 96 #define RunOneTruncationTest(p1, p2) RunOneTruncationTestWithTest(func, p1, p2)
93 97
94 void RunAllTruncationTests(ConvertDToIFunc func) { 98 void RunAllTruncationTests(ConvertDToIFunc func) {
95 RunOneTruncationTest(0, 0); 99 RunOneTruncationTest(0, 0);
96 RunOneTruncationTest(0.5, 0); 100 RunOneTruncationTest(0.5, 0);
97 RunOneTruncationTest(-0.5, 0); 101 RunOneTruncationTest(-0.5, 0);
98 RunOneTruncationTest(1.5, 1); 102 RunOneTruncationTest(1.5, 1);
99 RunOneTruncationTest(-1.5, -1); 103 RunOneTruncationTest(-1.5, -1);
100 RunOneTruncationTest(5.5, 5); 104 RunOneTruncationTest(5.5, 5);
101 RunOneTruncationTest(-5.0, -5); 105 RunOneTruncationTest(-5.0, -5);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, esi, edx)); 269 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, esi, edx));
266 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, esi, edi)); 270 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, esi, edi));
267 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, esi, esi)); 271 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, esi, esi));
268 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, eax)); 272 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, eax));
269 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, ebx)); 273 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, ebx));
270 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, ecx)); 274 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, ecx));
271 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, edx)); 275 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, edx));
272 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, edi)); 276 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, edi));
273 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, esi)); 277 RunAllTruncationTests(MakeConvertDToIFuncTrampoline(isolate, edi, esi));
274 } 278 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698