OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // ------------------------------------------------------------------------- | 36 // ------------------------------------------------------------------------- |
37 // Result implementation. | 37 // Result implementation. |
38 | 38 |
39 void Result::ToRegister() { | 39 void Result::ToRegister() { |
40 ASSERT(is_valid()); | 40 ASSERT(is_valid()); |
41 if (is_constant()) { | 41 if (is_constant()) { |
42 Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(); | 42 Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(); |
43 ASSERT(fresh.is_valid()); | 43 ASSERT(fresh.is_valid()); |
44 if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { | 44 if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { |
45 CodeGeneratorScope::Current()->LoadUnsafeSmi(fresh.reg(), handle()); | 45 CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle()); |
46 } else { | 46 } else { |
47 CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), | 47 CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), |
48 Immediate(handle())); | 48 Immediate(handle())); |
49 } | 49 } |
50 // This result becomes a copy of the fresh one. | 50 // This result becomes a copy of the fresh one. |
51 *this = fresh; | 51 *this = fresh; |
52 } | 52 } |
53 ASSERT(is_register()); | 53 ASSERT(is_register()); |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 void Result::ToRegister(Register target) { | 57 void Result::ToRegister(Register target) { |
58 ASSERT(is_valid()); | 58 ASSERT(is_valid()); |
59 if (!is_register() || !reg().is(target)) { | 59 if (!is_register() || !reg().is(target)) { |
60 Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(target); | 60 Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(target); |
61 ASSERT(fresh.is_valid()); | 61 ASSERT(fresh.is_valid()); |
62 if (is_register()) { | 62 if (is_register()) { |
63 CodeGeneratorScope::Current()->masm()->mov(fresh.reg(), reg()); | 63 CodeGeneratorScope::Current()->masm()->mov(fresh.reg(), reg()); |
64 } else { | 64 } else { |
65 ASSERT(is_constant()); | 65 ASSERT(is_constant()); |
66 if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { | 66 if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { |
67 CodeGeneratorScope::Current()->LoadUnsafeSmi(fresh.reg(), handle()); | 67 CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle()); |
68 } else { | 68 } else { |
69 CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), | 69 CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), |
70 Immediate(handle())); | 70 Immediate(handle())); |
71 } | 71 } |
72 } | 72 } |
73 *this = fresh; | 73 *this = fresh; |
74 } else if (is_register() && reg().is(target)) { | 74 } else if (is_register() && reg().is(target)) { |
75 ASSERT(CodeGeneratorScope::Current()->has_valid_frame()); | 75 ASSERT(CodeGeneratorScope::Current()->has_valid_frame()); |
76 CodeGeneratorScope::Current()->frame()->Spill(target); | 76 CodeGeneratorScope::Current()->frame()->Spill(target); |
77 ASSERT(CodeGeneratorScope::Current()->allocator()->count(target) == 1); | 77 ASSERT(CodeGeneratorScope::Current()->allocator()->count(target) == 1); |
(...skipping 12 matching lines...) Expand all Loading... |
90 // register if valid and return an invalid result. | 90 // register if valid and return an invalid result. |
91 if (result.is_valid() && !result.reg().is_byte_register()) { | 91 if (result.is_valid() && !result.reg().is_byte_register()) { |
92 result.Unuse(); | 92 result.Unuse(); |
93 return Result(); | 93 return Result(); |
94 } | 94 } |
95 return result; | 95 return result; |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 } } // namespace v8::internal | 99 } } // namespace v8::internal |
OLD | NEW |