| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // A light-weight assembler for the Regexp2000 byte code. | 28 // A light-weight assembler for the Irregexp byte code. |
| 29 | 29 |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 #include "ast.h" | 32 #include "ast.h" |
| 33 #include "bytecodes-re2k.h" | 33 #include "bytecodes-irregexp.h" |
| 34 #include "assembler-re2k.h" | 34 #include "assembler-irregexp.h" |
| 35 | 35 |
| 36 #include "assembler-re2k-inl.h" | 36 #include "assembler-irregexp-inl.h" |
| 37 | 37 |
| 38 | 38 |
| 39 namespace v8 { namespace internal { | 39 namespace v8 { namespace internal { |
| 40 | 40 |
| 41 | 41 |
| 42 Re2kAssembler::Re2kAssembler(Vector<byte> buffer) | 42 IrregexpAssembler::IrregexpAssembler(Vector<byte> buffer) |
| 43 : buffer_(buffer), | 43 : buffer_(buffer), |
| 44 pc_(0), | 44 pc_(0), |
| 45 own_buffer_(false) { | 45 own_buffer_(false) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 Re2kAssembler::~Re2kAssembler() { | 49 IrregexpAssembler::~IrregexpAssembler() { |
| 50 if (own_buffer_) { | 50 if (own_buffer_) { |
| 51 buffer_.Dispose(); | 51 buffer_.Dispose(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 void Re2kAssembler::PushCurrentPosition(int cp_offset) { | 56 void IrregexpAssembler::PushCurrentPosition(int cp_offset) { |
| 57 ASSERT(cp_offset >= 0); | 57 ASSERT(cp_offset >= 0); |
| 58 Emit(BC_PUSH_CP); | 58 Emit(BC_PUSH_CP); |
| 59 Emit32(cp_offset); | 59 Emit32(cp_offset); |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 void Re2kAssembler::PushBacktrack(Label* l) { | 63 void IrregexpAssembler::PushBacktrack(Label* l) { |
| 64 Emit(BC_PUSH_BT); | 64 Emit(BC_PUSH_BT); |
| 65 EmitOrLink(l); | 65 EmitOrLink(l); |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 void Re2kAssembler::PushRegister(int index) { | 69 void IrregexpAssembler::PushRegister(int index) { |
| 70 ASSERT(index >= 0); | 70 ASSERT(index >= 0); |
| 71 Emit(BC_PUSH_REGISTER); | 71 Emit(BC_PUSH_REGISTER); |
| 72 Emit(index); | 72 Emit(index); |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 void Re2kAssembler::WriteCurrentPositionToRegister(int index, int cp_offset) { | 76 void IrregexpAssembler::WriteCurrentPositionToRegister(int index, |
| 77 int cp_offset) { |
| 77 ASSERT(cp_offset >= 0); | 78 ASSERT(cp_offset >= 0); |
| 78 ASSERT(index >= 0); | 79 ASSERT(index >= 0); |
| 79 Emit(BC_SET_REGISTER_TO_CP); | 80 Emit(BC_SET_REGISTER_TO_CP); |
| 80 Emit(index); | 81 Emit(index); |
| 81 Emit32(cp_offset); | 82 Emit32(cp_offset); |
| 82 } | 83 } |
| 83 | 84 |
| 84 | 85 |
| 85 void Re2kAssembler::ReadCurrentPositionFromRegister(int index) { | 86 void IrregexpAssembler::ReadCurrentPositionFromRegister(int index) { |
| 86 ASSERT(index >= 0); | 87 ASSERT(index >= 0); |
| 87 Emit(BC_SET_CP_TO_REGISTER); | 88 Emit(BC_SET_CP_TO_REGISTER); |
| 88 Emit(index); | 89 Emit(index); |
| 89 } | 90 } |
| 90 | 91 |
| 91 | 92 |
| 92 void Re2kAssembler::WriteStackPointerToRegister(int index) { | 93 void IrregexpAssembler::WriteStackPointerToRegister(int index) { |
| 93 ASSERT(index >= 0); | 94 ASSERT(index >= 0); |
| 94 Emit(BC_SET_REGISTER_TO_SP); | 95 Emit(BC_SET_REGISTER_TO_SP); |
| 95 Emit(index); | 96 Emit(index); |
| 96 } | 97 } |
| 97 | 98 |
| 98 | 99 |
| 99 void Re2kAssembler::ReadStackPointerFromRegister(int index) { | 100 void IrregexpAssembler::ReadStackPointerFromRegister(int index) { |
| 100 ASSERT(index >= 0); | 101 ASSERT(index >= 0); |
| 101 Emit(BC_SET_SP_TO_REGISTER); | 102 Emit(BC_SET_SP_TO_REGISTER); |
| 102 Emit(index); | 103 Emit(index); |
| 103 } | 104 } |
| 104 | 105 |
| 105 | 106 |
| 106 void Re2kAssembler::SetRegister(int index, int value) { | 107 void IrregexpAssembler::SetRegister(int index, int value) { |
| 107 ASSERT(index >= 0); | 108 ASSERT(index >= 0); |
| 108 Emit(BC_SET_REGISTER); | 109 Emit(BC_SET_REGISTER); |
| 109 Emit(index); | 110 Emit(index); |
| 110 Emit32(value); | 111 Emit32(value); |
| 111 } | 112 } |
| 112 | 113 |
| 113 | 114 |
| 114 void Re2kAssembler::AdvanceRegister(int index, int by) { | 115 void IrregexpAssembler::AdvanceRegister(int index, int by) { |
| 115 ASSERT(index >= 0); | 116 ASSERT(index >= 0); |
| 116 Emit(BC_ADVANCE_REGISTER); | 117 Emit(BC_ADVANCE_REGISTER); |
| 117 Emit(index); | 118 Emit(index); |
| 118 Emit32(by); | 119 Emit32(by); |
| 119 } | 120 } |
| 120 | 121 |
| 121 | 122 |
| 122 void Re2kAssembler::PopCurrentPosition() { | 123 void IrregexpAssembler::PopCurrentPosition() { |
| 123 Emit(BC_POP_CP); | 124 Emit(BC_POP_CP); |
| 124 } | 125 } |
| 125 | 126 |
| 126 | 127 |
| 127 void Re2kAssembler::PopBacktrack() { | 128 void IrregexpAssembler::PopBacktrack() { |
| 128 Emit(BC_POP_BT); | 129 Emit(BC_POP_BT); |
| 129 } | 130 } |
| 130 | 131 |
| 131 | 132 |
| 132 void Re2kAssembler::PopRegister(int index) { | 133 void IrregexpAssembler::PopRegister(int index) { |
| 133 Emit(BC_POP_REGISTER); | 134 Emit(BC_POP_REGISTER); |
| 134 Emit(index); | 135 Emit(index); |
| 135 } | 136 } |
| 136 | 137 |
| 137 | 138 |
| 138 void Re2kAssembler::Fail() { | 139 void IrregexpAssembler::Fail() { |
| 139 Emit(BC_FAIL); | 140 Emit(BC_FAIL); |
| 140 } | 141 } |
| 141 | 142 |
| 142 | 143 |
| 143 void Re2kAssembler::Break() { | 144 void IrregexpAssembler::Break() { |
| 144 Emit(BC_BREAK); | 145 Emit(BC_BREAK); |
| 145 } | 146 } |
| 146 | 147 |
| 147 | 148 |
| 148 void Re2kAssembler::Succeed() { | 149 void IrregexpAssembler::Succeed() { |
| 149 Emit(BC_SUCCEED); | 150 Emit(BC_SUCCEED); |
| 150 } | 151 } |
| 151 | 152 |
| 152 | 153 |
| 153 void Re2kAssembler::Bind(Label* l) { | 154 void IrregexpAssembler::Bind(Label* l) { |
| 154 ASSERT(!l->is_bound()); | 155 ASSERT(!l->is_bound()); |
| 155 if (l->is_linked()) { | 156 if (l->is_linked()) { |
| 156 int pos = l->pos(); | 157 int pos = l->pos(); |
| 157 while (pos != 0) { | 158 while (pos != 0) { |
| 158 int fixup = pos; | 159 int fixup = pos; |
| 159 pos = Load32(buffer_.start() + fixup); | 160 pos = Load32(buffer_.start() + fixup); |
| 160 Store32(buffer_.start() + fixup, pc_); | 161 Store32(buffer_.start() + fixup, pc_); |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 l->bind_to(pc_); | 164 l->bind_to(pc_); |
| 164 } | 165 } |
| 165 | 166 |
| 166 | 167 |
| 167 void Re2kAssembler::AdvanceCP(int cp_offset) { | 168 void IrregexpAssembler::AdvanceCP(int cp_offset) { |
| 168 Emit(BC_ADVANCE_CP); | 169 Emit(BC_ADVANCE_CP); |
| 169 Emit32(cp_offset); | 170 Emit32(cp_offset); |
| 170 } | 171 } |
| 171 | 172 |
| 172 | 173 |
| 173 void Re2kAssembler::GoTo(Label* l) { | 174 void IrregexpAssembler::GoTo(Label* l) { |
| 174 Emit(BC_GOTO); | 175 Emit(BC_GOTO); |
| 175 EmitOrLink(l); | 176 EmitOrLink(l); |
| 176 } | 177 } |
| 177 | 178 |
| 178 | 179 |
| 179 void Re2kAssembler::LoadCurrentChar(int cp_offset, Label* on_end) { | 180 void IrregexpAssembler::LoadCurrentChar(int cp_offset, Label* on_end) { |
| 180 Emit(BC_LOAD_CURRENT_CHAR); | 181 Emit(BC_LOAD_CURRENT_CHAR); |
| 181 Emit32(cp_offset); | 182 Emit32(cp_offset); |
| 182 EmitOrLink(on_end); | 183 EmitOrLink(on_end); |
| 183 } | 184 } |
| 184 | 185 |
| 185 | 186 |
| 186 void Re2kAssembler::CheckCharacter(uc16 c, Label* on_match) { | 187 void IrregexpAssembler::CheckCharacter(uc16 c, Label* on_match) { |
| 187 Emit(BC_CHECK_CHAR); | 188 Emit(BC_CHECK_CHAR); |
| 188 Emit16(c); | 189 Emit16(c); |
| 189 EmitOrLink(on_match); | 190 EmitOrLink(on_match); |
| 190 } | 191 } |
| 191 | 192 |
| 192 | 193 |
| 193 void Re2kAssembler::CheckNotCharacter(uc16 c, Label* on_mismatch) { | 194 void IrregexpAssembler::CheckNotCharacter(uc16 c, Label* on_mismatch) { |
| 194 Emit(BC_CHECK_NOT_CHAR); | 195 Emit(BC_CHECK_NOT_CHAR); |
| 195 Emit16(c); | 196 Emit16(c); |
| 196 EmitOrLink(on_mismatch); | 197 EmitOrLink(on_mismatch); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void Re2kAssembler::OrThenCheckNotCharacter(uc16 c, | 200 void IrregexpAssembler::OrThenCheckNotCharacter(uc16 c, |
| 200 uc16 mask, | 201 uc16 mask, |
| 201 Label* on_mismatch) { | 202 Label* on_mismatch) { |
| 202 Emit(BC_OR_CHECK_NOT_CHAR); | 203 Emit(BC_OR_CHECK_NOT_CHAR); |
| 203 Emit16(c); | 204 Emit16(c); |
| 204 Emit16(mask); | 205 Emit16(mask); |
| 205 EmitOrLink(on_mismatch); | 206 EmitOrLink(on_mismatch); |
| 206 } | 207 } |
| 207 | 208 |
| 208 | 209 |
| 209 void Re2kAssembler::MinusOrThenCheckNotCharacter(uc16 c, | 210 void IrregexpAssembler::MinusOrThenCheckNotCharacter(uc16 c, |
| 210 uc16 mask, | 211 uc16 mask, |
| 211 Label* on_mismatch) { | 212 Label* on_mismatch) { |
| 212 Emit(BC_MINUS_OR_CHECK_NOT_CHAR); | 213 Emit(BC_MINUS_OR_CHECK_NOT_CHAR); |
| 213 Emit16(c); | 214 Emit16(c); |
| 214 Emit16(mask); | 215 Emit16(mask); |
| 215 EmitOrLink(on_mismatch); | 216 EmitOrLink(on_mismatch); |
| 216 } | 217 } |
| 217 | 218 |
| 218 | 219 |
| 219 void Re2kAssembler::CheckCharacterLT(uc16 limit, Label* on_less) { | 220 void IrregexpAssembler::CheckCharacterLT(uc16 limit, Label* on_less) { |
| 220 Emit(BC_CHECK_LT); | 221 Emit(BC_CHECK_LT); |
| 221 Emit16(limit); | 222 Emit16(limit); |
| 222 EmitOrLink(on_less); | 223 EmitOrLink(on_less); |
| 223 } | 224 } |
| 224 | 225 |
| 225 | 226 |
| 226 void Re2kAssembler::CheckCharacterGT(uc16 limit, Label* on_greater) { | 227 void IrregexpAssembler::CheckCharacterGT(uc16 limit, Label* on_greater) { |
| 227 Emit(BC_CHECK_GT); | 228 Emit(BC_CHECK_GT); |
| 228 Emit16(limit); | 229 Emit16(limit); |
| 229 EmitOrLink(on_greater); | 230 EmitOrLink(on_greater); |
| 230 } | 231 } |
| 231 | 232 |
| 232 | 233 |
| 233 void Re2kAssembler::CheckNotBackReference(int capture_index, | 234 void IrregexpAssembler::CheckNotBackReference(int capture_index, |
| 234 Label* on_mismatch) { | 235 Label* on_mismatch) { |
| 235 Emit(BC_CHECK_NOT_BACK_REF); | 236 Emit(BC_CHECK_NOT_BACK_REF); |
| 236 Emit(capture_index); | 237 Emit(capture_index); |
| 237 EmitOrLink(on_mismatch); | 238 EmitOrLink(on_mismatch); |
| 238 } | 239 } |
| 239 | 240 |
| 240 | 241 |
| 241 void Re2kAssembler::CheckRegister(int byte_code, | 242 void IrregexpAssembler::CheckRegister(int byte_code, |
| 242 int reg_index, | 243 int reg_index, |
| 243 uint16_t vs, | 244 uint16_t vs, |
| 244 Label* on_true) { | 245 Label* on_true) { |
| 245 Emit(byte_code); | 246 Emit(byte_code); |
| 246 Emit(reg_index); | 247 Emit(reg_index); |
| 247 Emit16(vs); | 248 Emit16(vs); |
| 248 EmitOrLink(on_true); | 249 EmitOrLink(on_true); |
| 249 } | 250 } |
| 250 | 251 |
| 251 | 252 |
| 252 void Re2kAssembler::CheckRegisterLT(int reg_index, | 253 void IrregexpAssembler::CheckRegisterLT(int reg_index, |
| 253 uint16_t vs, | 254 uint16_t vs, |
| 254 Label* on_less_than) { | 255 Label* on_less_than) { |
| 255 CheckRegister(BC_CHECK_REGISTER_LT, reg_index, vs, on_less_than); | 256 CheckRegister(BC_CHECK_REGISTER_LT, reg_index, vs, on_less_than); |
| 256 } | 257 } |
| 257 | 258 |
| 258 | 259 |
| 259 void Re2kAssembler::CheckRegisterGE(int reg_index, | 260 void IrregexpAssembler::CheckRegisterGE(int reg_index, |
| 260 uint16_t vs, | 261 uint16_t vs, |
| 261 Label* on_greater_than_equal) { | 262 Label* on_greater_than_equal) { |
| 262 CheckRegister(BC_CHECK_REGISTER_GE, reg_index, vs, on_greater_than_equal); | 263 CheckRegister(BC_CHECK_REGISTER_GE, reg_index, vs, on_greater_than_equal); |
| 263 } | 264 } |
| 264 | 265 |
| 265 | 266 |
| 266 void Re2kAssembler::LookupMap1(uc16 start, Label* bit_map, Label* on_zero) { | 267 void IrregexpAssembler::LookupMap1(uc16 start, Label* bit_map, Label* on_zero) { |
| 267 Emit(BC_LOOKUP_MAP1); | 268 Emit(BC_LOOKUP_MAP1); |
| 268 Emit16(start); | 269 Emit16(start); |
| 269 EmitOrLink(bit_map); | 270 EmitOrLink(bit_map); |
| 270 EmitOrLink(on_zero); | 271 EmitOrLink(on_zero); |
| 271 } | 272 } |
| 272 | 273 |
| 273 | 274 |
| 274 void Re2kAssembler::LookupMap2(uc16 start, | 275 void IrregexpAssembler::LookupMap2(uc16 start, |
| 275 Label* half_nibble_map, | 276 Label* half_nibble_map, |
| 276 const Vector<Label*>& table) { | 277 const Vector<Label*>& table) { |
| 277 Emit(BC_LOOKUP_MAP2); | 278 Emit(BC_LOOKUP_MAP2); |
| 278 Emit16(start); | 279 Emit16(start); |
| 279 EmitOrLink(half_nibble_map); | 280 EmitOrLink(half_nibble_map); |
| 280 ASSERT(table.length() > 0); | 281 ASSERT(table.length() > 0); |
| 281 ASSERT(table.length() <= 4); | 282 ASSERT(table.length() <= 4); |
| 282 for (int i = 0; i < table.length(); i++) { | 283 for (int i = 0; i < table.length(); i++) { |
| 283 EmitOrLink(table[i]); | 284 EmitOrLink(table[i]); |
| 284 } | 285 } |
| 285 } | 286 } |
| 286 | 287 |
| 287 | 288 |
| 288 void Re2kAssembler::LookupMap8(uc16 start, | 289 void IrregexpAssembler::LookupMap8(uc16 start, |
| 289 Label* byte_map, | 290 Label* byte_map, |
| 290 const Vector<Label*>& table) { | 291 const Vector<Label*>& table) { |
| 291 Emit(BC_LOOKUP_MAP8); | 292 Emit(BC_LOOKUP_MAP8); |
| 292 Emit16(start); | 293 Emit16(start); |
| 293 EmitOrLink(byte_map); | 294 EmitOrLink(byte_map); |
| 294 ASSERT(table.length() > 0); | 295 ASSERT(table.length() > 0); |
| 295 ASSERT(table.length() <= 256); | 296 ASSERT(table.length() <= 256); |
| 296 for (int i = 0; i < table.length(); i++) { | 297 for (int i = 0; i < table.length(); i++) { |
| 297 EmitOrLink(table[i]); | 298 EmitOrLink(table[i]); |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 | 301 |
| 301 | 302 |
| 302 void Re2kAssembler::LookupHighMap8(byte start, | 303 void IrregexpAssembler::LookupHighMap8(byte start, |
| 303 Label* byte_map, | 304 Label* byte_map, |
| 304 const Vector<Label*>& table) { | 305 const Vector<Label*>& table) { |
| 305 Emit(BC_LOOKUP_HI_MAP8); | 306 Emit(BC_LOOKUP_HI_MAP8); |
| 306 Emit(start); | 307 Emit(start); |
| 307 EmitOrLink(byte_map); | 308 EmitOrLink(byte_map); |
| 308 ASSERT(table.length() > 0); | 309 ASSERT(table.length() > 0); |
| 309 ASSERT(table.length() <= 256); | 310 ASSERT(table.length() <= 256); |
| 310 for (int i = 0; i < table.length(); i++) { | 311 for (int i = 0; i < table.length(); i++) { |
| 311 EmitOrLink(table[i]); | 312 EmitOrLink(table[i]); |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 | 315 |
| 315 | 316 |
| 316 int Re2kAssembler::length() { | 317 int IrregexpAssembler::length() { |
| 317 return pc_; | 318 return pc_; |
| 318 } | 319 } |
| 319 | 320 |
| 320 | 321 |
| 321 void Re2kAssembler::Copy(Address a) { | 322 void IrregexpAssembler::Copy(Address a) { |
| 322 memcpy(a, buffer_.start(), length()); | 323 memcpy(a, buffer_.start(), length()); |
| 323 } | 324 } |
| 324 | 325 |
| 325 | 326 |
| 326 void Re2kAssembler::Expand() { | 327 void IrregexpAssembler::Expand() { |
| 327 bool old_buffer_was_our_own = own_buffer_; | 328 bool old_buffer_was_our_own = own_buffer_; |
| 328 Vector<byte> old_buffer = buffer_; | 329 Vector<byte> old_buffer = buffer_; |
| 329 buffer_ = Vector<byte>::New(old_buffer.length() * 2); | 330 buffer_ = Vector<byte>::New(old_buffer.length() * 2); |
| 330 own_buffer_ = true; | 331 own_buffer_ = true; |
| 331 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); | 332 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); |
| 332 if (old_buffer_was_our_own) { | 333 if (old_buffer_was_our_own) { |
| 333 old_buffer.Dispose(); | 334 old_buffer.Dispose(); |
| 334 } | 335 } |
| 335 } | 336 } |
| 336 | 337 |
| 337 | 338 |
| 338 } } // namespace v8::internal | 339 } } // namespace v8::internal |
| OLD | NEW |