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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 size_t actual_size; | 146 size_t actual_size; |
147 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 147 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
148 &actual_size, | 148 &actual_size, |
149 true)); | 149 true)); |
150 CHECK(buffer); | 150 CHECK(buffer); |
151 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); | 151 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); |
152 | 152 |
153 // Assemble a simple function that multiplies arguments returning the high | 153 // Assemble a simple function that multiplies arguments returning the high |
154 // word. | 154 // word. |
155 __ movq(rax, arg2); | 155 __ movq(rax, arg2); |
156 __ imul(arg1); | 156 __ imulq(arg1); |
157 __ movq(rax, rdx); | 157 __ movq(rax, rdx); |
158 __ ret(0); | 158 __ ret(0); |
159 | 159 |
160 CodeDesc desc; | 160 CodeDesc desc; |
161 assm.GetCode(&desc); | 161 assm.GetCode(&desc); |
162 // Call the function from C++. | 162 // Call the function from C++. |
163 int result = FUNCTION_CAST<F2>(buffer)(3, 2); | 163 int result = FUNCTION_CAST<F2>(buffer)(3, 2); |
164 CHECK_EQ(0, result); | 164 CHECK_EQ(0, result); |
165 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l); | 165 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l); |
166 CHECK_EQ(1, result); | 166 CHECK_EQ(1, result); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 Handle<Code>())->ToObjectChecked()); | 706 Handle<Code>())->ToObjectChecked()); |
707 CHECK(code->IsCode()); | 707 CHECK(code->IsCode()); |
708 #ifdef OBJECT_PRINT | 708 #ifdef OBJECT_PRINT |
709 Code::cast(code)->Print(); | 709 Code::cast(code)->Print(); |
710 #endif | 710 #endif |
711 | 711 |
712 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); | 712 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); |
713 CHECK_EQ(2, f(1.0, 2.0)); | 713 CHECK_EQ(2, f(1.0, 2.0)); |
714 } | 714 } |
715 #undef __ | 715 #undef __ |
OLD | NEW |