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 22 matching lines...) Expand all Loading... |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 // ------------------------------------------------------------------------- | 36 // ------------------------------------------------------------------------- |
37 // Result implementation. | 37 // Result implementation. |
38 | 38 |
39 | 39 |
40 Result::Result(Register reg) { | 40 Result::Result(Register reg) { |
41 ASSERT(reg.is_valid() && !RegisterAllocator::IsReserved(reg)); | 41 ASSERT(reg.is_valid() && !RegisterAllocator::IsReserved(reg)); |
42 CodeGeneratorScope::Current()->allocator()->Use(reg); | 42 CodeGeneratorScope::Current()->allocator()->Use(reg); |
43 value_ = StaticTypeField::encode(StaticType::UNKNOWN_TYPE) | 43 value_ = TypeField::encode(REGISTER) | DataField::encode(reg.code_); |
44 | TypeField::encode(REGISTER) | |
45 | DataField::encode(reg.code_); | |
46 } | 44 } |
47 | 45 |
48 | 46 |
49 Result::Result(Register reg, StaticType type) { | |
50 ASSERT(reg.is_valid() && !RegisterAllocator::IsReserved(reg)); | |
51 CodeGeneratorScope::Current()->allocator()->Use(reg); | |
52 value_ = StaticTypeField::encode(type.static_type_) | |
53 | TypeField::encode(REGISTER) | |
54 | DataField::encode(reg.code_); | |
55 } | |
56 | |
57 | |
58 // ------------------------------------------------------------------------- | 47 // ------------------------------------------------------------------------- |
59 // RegisterAllocator implementation. | 48 // RegisterAllocator implementation. |
60 | 49 |
61 | 50 |
62 Result RegisterAllocator::AllocateWithoutSpilling() { | 51 Result RegisterAllocator::AllocateWithoutSpilling() { |
63 // Return the first free register, if any. | 52 // Return the first free register, if any. |
64 int num = registers_.ScanForFreeRegister(); | 53 int num = registers_.ScanForFreeRegister(); |
65 if (num == RegisterAllocator::kInvalidRegister) { | 54 if (num == RegisterAllocator::kInvalidRegister) { |
66 return Result(); | 55 return Result(); |
67 } | 56 } |
(...skipping 28 matching lines...) Expand all Loading... |
96 cgen_->frame()->Spill(target); | 85 cgen_->frame()->Spill(target); |
97 ASSERT(!is_used(target)); | 86 ASSERT(!is_used(target)); |
98 return Result(target); | 87 return Result(target); |
99 } | 88 } |
100 // Otherwise (if it's referenced outside the frame) we cannot allocate it. | 89 // Otherwise (if it's referenced outside the frame) we cannot allocate it. |
101 return Result(); | 90 return Result(); |
102 } | 91 } |
103 | 92 |
104 | 93 |
105 } } // namespace v8::internal | 94 } } // namespace v8::internal |
OLD | NEW |