OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 __ mov(eax, Operand(esp, 4)); | 57 __ mov(eax, Operand(esp, 4)); |
58 __ add(eax, Operand(esp, 8)); | 58 __ add(eax, Operand(esp, 8)); |
59 __ ret(0); | 59 __ ret(0); |
60 | 60 |
61 CodeDesc desc; | 61 CodeDesc desc; |
62 assm.GetCode(&desc); | 62 assm.GetCode(&desc); |
63 Handle<Code> code = isolate->factory()->NewCode( | 63 Handle<Code> code = isolate->factory()->NewCode( |
64 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 64 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
65 #ifdef OBJECT_PRINT | 65 #ifdef OBJECT_PRINT |
66 code->Print(); | 66 OFStream os(stdout); |
| 67 code->Print(os); |
67 #endif | 68 #endif |
68 F2 f = FUNCTION_CAST<F2>(code->entry()); | 69 F2 f = FUNCTION_CAST<F2>(code->entry()); |
69 int res = f(3, 4); | 70 int res = f(3, 4); |
70 ::printf("f() = %d\n", res); | 71 ::printf("f() = %d\n", res); |
71 CHECK_EQ(7, res); | 72 CHECK_EQ(7, res); |
72 } | 73 } |
73 | 74 |
74 | 75 |
75 TEST(AssemblerIa321) { | 76 TEST(AssemblerIa321) { |
76 CcTest::InitializeVM(); | 77 CcTest::InitializeVM(); |
(...skipping 15 matching lines...) Expand all Loading... |
92 __ bind(&C); | 93 __ bind(&C); |
93 __ test(edx, edx); | 94 __ test(edx, edx); |
94 __ j(not_zero, &L); | 95 __ j(not_zero, &L); |
95 __ ret(0); | 96 __ ret(0); |
96 | 97 |
97 CodeDesc desc; | 98 CodeDesc desc; |
98 assm.GetCode(&desc); | 99 assm.GetCode(&desc); |
99 Handle<Code> code = isolate->factory()->NewCode( | 100 Handle<Code> code = isolate->factory()->NewCode( |
100 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 101 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
101 #ifdef OBJECT_PRINT | 102 #ifdef OBJECT_PRINT |
102 code->Print(); | 103 OFStream os(stdout); |
| 104 code->Print(os); |
103 #endif | 105 #endif |
104 F1 f = FUNCTION_CAST<F1>(code->entry()); | 106 F1 f = FUNCTION_CAST<F1>(code->entry()); |
105 int res = f(100); | 107 int res = f(100); |
106 ::printf("f() = %d\n", res); | 108 ::printf("f() = %d\n", res); |
107 CHECK_EQ(5050, res); | 109 CHECK_EQ(5050, res); |
108 } | 110 } |
109 | 111 |
110 | 112 |
111 TEST(AssemblerIa322) { | 113 TEST(AssemblerIa322) { |
112 CcTest::InitializeVM(); | 114 CcTest::InitializeVM(); |
(...skipping 19 matching lines...) Expand all Loading... |
132 | 134 |
133 // some relocated stuff here, not executed | 135 // some relocated stuff here, not executed |
134 __ mov(eax, isolate->factory()->true_value()); | 136 __ mov(eax, isolate->factory()->true_value()); |
135 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); | 137 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); |
136 | 138 |
137 CodeDesc desc; | 139 CodeDesc desc; |
138 assm.GetCode(&desc); | 140 assm.GetCode(&desc); |
139 Handle<Code> code = isolate->factory()->NewCode( | 141 Handle<Code> code = isolate->factory()->NewCode( |
140 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 142 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
141 #ifdef OBJECT_PRINT | 143 #ifdef OBJECT_PRINT |
142 code->Print(); | 144 OFStream os(stdout); |
| 145 code->Print(os); |
143 #endif | 146 #endif |
144 F1 f = FUNCTION_CAST<F1>(code->entry()); | 147 F1 f = FUNCTION_CAST<F1>(code->entry()); |
145 int res = f(10); | 148 int res = f(10); |
146 ::printf("f() = %d\n", res); | 149 ::printf("f() = %d\n", res); |
147 CHECK_EQ(3628800, res); | 150 CHECK_EQ(3628800, res); |
148 } | 151 } |
149 | 152 |
150 | 153 |
151 typedef int (*F3)(float x); | 154 typedef int (*F3)(float x); |
152 | 155 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 __ bind(&nan_l); | 213 __ bind(&nan_l); |
211 __ mov(eax, kNaN); | 214 __ mov(eax, kNaN); |
212 __ ret(0); | 215 __ ret(0); |
213 | 216 |
214 | 217 |
215 CodeDesc desc; | 218 CodeDesc desc; |
216 assm.GetCode(&desc); | 219 assm.GetCode(&desc); |
217 Handle<Code> code = isolate->factory()->NewCode( | 220 Handle<Code> code = isolate->factory()->NewCode( |
218 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 221 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
219 #ifdef OBJECT_PRINT | 222 #ifdef OBJECT_PRINT |
220 code->Print(); | 223 OFStream os(stdout); |
| 224 code->Print(os); |
221 #endif | 225 #endif |
222 | 226 |
223 F7 f = FUNCTION_CAST<F7>(code->entry()); | 227 F7 f = FUNCTION_CAST<F7>(code->entry()); |
224 CHECK_EQ(kLess, f(1.1, 2.2)); | 228 CHECK_EQ(kLess, f(1.1, 2.2)); |
225 CHECK_EQ(kEqual, f(2.2, 2.2)); | 229 CHECK_EQ(kEqual, f(2.2, 2.2)); |
226 CHECK_EQ(kGreater, f(3.3, 2.2)); | 230 CHECK_EQ(kGreater, f(3.3, 2.2)); |
227 CHECK_EQ(kNaN, f(v8::base::OS::nan_value(), 1.1)); | 231 CHECK_EQ(kNaN, f(v8::base::OS::nan_value(), 1.1)); |
228 } | 232 } |
229 | 233 |
230 | 234 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 305 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
302 CHECK(code->IsCode()); | 306 CHECK(code->IsCode()); |
303 | 307 |
304 F0 f = FUNCTION_CAST<F0>(code->entry()); | 308 F0 f = FUNCTION_CAST<F0>(code->entry()); |
305 int res = f(); | 309 int res = f(); |
306 CHECK_EQ(42, res); | 310 CHECK_EQ(42, res); |
307 } | 311 } |
308 | 312 |
309 | 313 |
310 #undef __ | 314 #undef __ |
OLD | NEW |