| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 __ add(eax, Operand(esp, 8)); | 67 __ add(eax, Operand(esp, 8)); |
| 68 __ ret(0); | 68 __ ret(0); |
| 69 | 69 |
| 70 CodeDesc desc; | 70 CodeDesc desc; |
| 71 assm.GetCode(&desc); | 71 assm.GetCode(&desc); |
| 72 Object* code = Heap::CreateCode(desc, | 72 Object* code = Heap::CreateCode(desc, |
| 73 Code::ComputeFlags(Code::STUB), | 73 Code::ComputeFlags(Code::STUB), |
| 74 Handle<Object>(Heap::undefined_value()))-> | 74 Handle<Object>(Heap::undefined_value()))-> |
| 75 ToObjectChecked(); | 75 ToObjectChecked(); |
| 76 CHECK(code->IsCode()); | 76 CHECK(code->IsCode()); |
| 77 #ifdef PRINT_OBJECT | 77 #ifdef OBJECT_PRINT |
| 78 Code::cast(code)->Print(); | 78 Code::cast(code)->Print(); |
| 79 #endif | 79 #endif |
| 80 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); | 80 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); |
| 81 int res = f(3, 4); | 81 int res = f(3, 4); |
| 82 ::printf("f() = %d\n", res); | 82 ::printf("f() = %d\n", res); |
| 83 CHECK_EQ(7, res); | 83 CHECK_EQ(7, res); |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 TEST(AssemblerIa321) { | 87 TEST(AssemblerIa321) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 105 __ j(not_zero, &L, taken); | 105 __ j(not_zero, &L, taken); |
| 106 __ ret(0); | 106 __ ret(0); |
| 107 | 107 |
| 108 CodeDesc desc; | 108 CodeDesc desc; |
| 109 assm.GetCode(&desc); | 109 assm.GetCode(&desc); |
| 110 Object* code = Heap::CreateCode(desc, | 110 Object* code = Heap::CreateCode(desc, |
| 111 Code::ComputeFlags(Code::STUB), | 111 Code::ComputeFlags(Code::STUB), |
| 112 Handle<Object>(Heap::undefined_value()))-> | 112 Handle<Object>(Heap::undefined_value()))-> |
| 113 ToObjectChecked(); | 113 ToObjectChecked(); |
| 114 CHECK(code->IsCode()); | 114 CHECK(code->IsCode()); |
| 115 #ifdef PRINT_OBJECT | 115 #ifdef OBJECT_PRINT |
| 116 Code::cast(code)->Print(); | 116 Code::cast(code)->Print(); |
| 117 #endif | 117 #endif |
| 118 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 118 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); |
| 119 int res = f(100); | 119 int res = f(100); |
| 120 ::printf("f() = %d\n", res); | 120 ::printf("f() = %d\n", res); |
| 121 CHECK_EQ(5050, res); | 121 CHECK_EQ(5050, res); |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 TEST(AssemblerIa322) { | 125 TEST(AssemblerIa322) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 148 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); | 148 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); |
| 149 | 149 |
| 150 CodeDesc desc; | 150 CodeDesc desc; |
| 151 assm.GetCode(&desc); | 151 assm.GetCode(&desc); |
| 152 Object* code = Heap::CreateCode( | 152 Object* code = Heap::CreateCode( |
| 153 desc, | 153 desc, |
| 154 Code::ComputeFlags(Code::STUB), | 154 Code::ComputeFlags(Code::STUB), |
| 155 Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); | 155 Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); |
| 156 | 156 |
| 157 CHECK(code->IsCode()); | 157 CHECK(code->IsCode()); |
| 158 #ifdef PRINT_OBJECT | 158 #ifdef OBJECT_PRINT |
| 159 Code::cast(code)->Print(); | 159 Code::cast(code)->Print(); |
| 160 #endif | 160 #endif |
| 161 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 161 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); |
| 162 int res = f(10); | 162 int res = f(10); |
| 163 ::printf("f() = %d\n", res); | 163 ::printf("f() = %d\n", res); |
| 164 CHECK_EQ(3628800, res); | 164 CHECK_EQ(3628800, res); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 typedef int (*F3)(float x); | 168 typedef int (*F3)(float x); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 __ fld_d(Operand(esp, 0)); | 322 __ fld_d(Operand(esp, 0)); |
| 323 __ add(Operand(esp), Immediate(8)); | 323 __ add(Operand(esp), Immediate(8)); |
| 324 __ ret(0); | 324 __ ret(0); |
| 325 CodeDesc desc; | 325 CodeDesc desc; |
| 326 assm.GetCode(&desc); | 326 assm.GetCode(&desc); |
| 327 Code* code = Code::cast(Heap::CreateCode( | 327 Code* code = Code::cast(Heap::CreateCode( |
| 328 desc, | 328 desc, |
| 329 Code::ComputeFlags(Code::STUB), | 329 Code::ComputeFlags(Code::STUB), |
| 330 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); | 330 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); |
| 331 CHECK(code->IsCode()); | 331 CHECK(code->IsCode()); |
| 332 #ifdef PRINT_OBJECT | 332 #ifdef OBJECT_PRINT |
| 333 Code::cast(code)->Print(); | 333 Code::cast(code)->Print(); |
| 334 #endif | 334 #endif |
| 335 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); | 335 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); |
| 336 double res = f(12); | 336 double res = f(12); |
| 337 | 337 |
| 338 ::printf("f() = %f\n", res); | 338 ::printf("f() = %f\n", res); |
| 339 CHECK(11.99 < res && res < 12.001); | 339 CHECK(11.99 < res && res < 12.001); |
| 340 } | 340 } |
| 341 | 341 |
| 342 | 342 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 __ ret(0); | 377 __ ret(0); |
| 378 | 378 |
| 379 | 379 |
| 380 CodeDesc desc; | 380 CodeDesc desc; |
| 381 assm.GetCode(&desc); | 381 assm.GetCode(&desc); |
| 382 Code* code = Code::cast(Heap::CreateCode( | 382 Code* code = Code::cast(Heap::CreateCode( |
| 383 desc, | 383 desc, |
| 384 Code::ComputeFlags(Code::STUB), | 384 Code::ComputeFlags(Code::STUB), |
| 385 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); | 385 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); |
| 386 CHECK(code->IsCode()); | 386 CHECK(code->IsCode()); |
| 387 #ifdef PRINT_OBJECT | 387 #ifdef OBJECT_PRINT |
| 388 Code::cast(code)->Print(); | 388 Code::cast(code)->Print(); |
| 389 #endif | 389 #endif |
| 390 | 390 |
| 391 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); | 391 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); |
| 392 CHECK_EQ(kLess, f(1.1, 2.2)); | 392 CHECK_EQ(kLess, f(1.1, 2.2)); |
| 393 CHECK_EQ(kEqual, f(2.2, 2.2)); | 393 CHECK_EQ(kEqual, f(2.2, 2.2)); |
| 394 CHECK_EQ(kGreater, f(3.3, 2.2)); | 394 CHECK_EQ(kGreater, f(3.3, 2.2)); |
| 395 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); | 395 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); |
| 396 } | 396 } |
| 397 | 397 |
| 398 #undef __ | 398 #undef __ |
| OLD | NEW |