| 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 20 matching lines...) Expand all Loading... |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 #include "ast.h" | 32 #include "ast.h" |
| 33 #include "bytecodes-re2k.h" | 33 #include "bytecodes-re2k.h" |
| 34 #include "assembler-re2k.h" | 34 #include "assembler-re2k.h" |
| 35 | 35 |
| 36 | 36 |
| 37 namespace v8 { namespace internal { | 37 namespace v8 { namespace internal { |
| 38 | 38 |
| 39 | 39 |
| 40 void Re2kAssembler::Emit(uint32_t byte) { | 40 void Re2kAssembler::Emit(uint32_t byte) { |
| 41 ASSERT(pc_ <= buffer_.length()); |
| 42 if (pc_ == buffer_.length()) { |
| 43 Expand(); |
| 44 } |
| 41 buffer_[pc_++] = byte; | 45 buffer_[pc_++] = byte; |
| 42 } | 46 } |
| 43 | 47 |
| 44 | 48 |
| 45 void Re2kAssembler::Emit16(uint32_t word) { | 49 void Re2kAssembler::Emit16(uint32_t word) { |
| 50 ASSERT(pc_ <= buffer_.length()); |
| 51 if (pc_ + 1 >= buffer_.length()) { |
| 52 Expand(); |
| 53 } |
| 46 Store16(buffer_.start() + pc_, word); | 54 Store16(buffer_.start() + pc_, word); |
| 47 pc_ += 2; | 55 pc_ += 2; |
| 48 } | 56 } |
| 49 | 57 |
| 50 | 58 |
| 51 void Re2kAssembler::Emit32(uint32_t word) { | 59 void Re2kAssembler::Emit32(uint32_t word) { |
| 60 ASSERT(pc_ <= buffer_.length()); |
| 61 if (pc_ + 3 >= buffer_.length()) { |
| 62 Expand(); |
| 63 } |
| 52 Store32(buffer_.start() + pc_, word); | 64 Store32(buffer_.start() + pc_, word); |
| 53 pc_ += 4; | 65 pc_ += 4; |
| 54 } | 66 } |
| 55 | 67 |
| 56 | 68 |
| 57 void Re2kAssembler::EmitOrLink(Label* l) { | 69 void Re2kAssembler::EmitOrLink(Label* l) { |
| 58 if (l->is_bound()) { | 70 if (l->is_bound()) { |
| 59 Emit32(l->pos()); | 71 Emit32(l->pos()); |
| 60 } else { | 72 } else { |
| 61 int pos = 0; | 73 int pos = 0; |
| 62 if (l->is_linked()) { | 74 if (l->is_linked()) { |
| 63 pos = l->pos(); | 75 pos = l->pos(); |
| 64 } | 76 } |
| 65 l->link_to(pc_); | 77 l->link_to(pc_); |
| 66 Emit32(pos); | 78 Emit32(pos); |
| 67 } | 79 } |
| 68 } | 80 } |
| 69 | 81 |
| 70 } } // namespace v8::internal | 82 } } // namespace v8::internal |
| OLD | NEW |