| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 if (result == EXCEPTION && !Isolate::Current()->has_pending_exception()) { | 179 if (result == EXCEPTION && !Isolate::Current()->has_pending_exception()) { |
| 180 // We detected a stack overflow (on the backtrack stack) in RegExp code, | 180 // We detected a stack overflow (on the backtrack stack) in RegExp code, |
| 181 // but haven't created the exception yet. | 181 // but haven't created the exception yet. |
| 182 Isolate::Current()->StackOverflow(); | 182 Isolate::Current()->StackOverflow(); |
| 183 } | 183 } |
| 184 return static_cast<Result>(result); | 184 return static_cast<Result>(result); |
| 185 } | 185 } |
| 186 | 186 |
| 187 | 187 |
| 188 static unibrow::Mapping<unibrow::Ecma262Canonicalize> canonicalize; | 188 const byte NativeRegExpMacroAssembler::word_character_map[] = { |
| 189 | |
| 190 | |
| 191 byte NativeRegExpMacroAssembler::word_character_map[] = { | |
| 192 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, | 189 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, |
| 193 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, | 190 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, |
| 194 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, | 191 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, |
| 195 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, | 192 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, |
| 196 | 193 |
| 197 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, | 194 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, |
| 198 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, | 195 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, |
| 199 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // '0' - '7' | 196 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // '0' - '7' |
| 200 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, // '8' - '9' | 197 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, // '8' - '9' |
| 201 | 198 |
| 202 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'A' - 'G' | 199 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'A' - 'G' |
| 203 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'H' - 'O' | 200 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'H' - 'O' |
| 204 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'P' - 'W' | 201 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'P' - 'W' |
| 205 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, 0xffu, // 'X' - 'Z', '_' | 202 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, 0xffu, // 'X' - 'Z', '_' |
| 206 | 203 |
| 207 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'a' - 'g' | 204 0x00u, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'a' - 'g' |
| 208 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'h' - 'o' | 205 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'h' - 'o' |
| 209 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'p' - 'w' | 206 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, // 'p' - 'w' |
| 210 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, // 'x' - 'z' | 207 0xffu, 0xffu, 0xffu, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, // 'x' - 'z' |
| 211 }; | 208 }; |
| 212 | 209 |
| 213 | 210 |
| 214 int NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16( | 211 int NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16( |
| 215 Address byte_offset1, | 212 Address byte_offset1, |
| 216 Address byte_offset2, | 213 Address byte_offset2, |
| 217 size_t byte_length) { | 214 size_t byte_length) { |
| 215 unibrow::Mapping<unibrow::Ecma262Canonicalize>* canonicalize = |
| 216 Isolate::Current()->regexp_macro_assembler_canonicalize(); |
| 218 // This function is not allowed to cause a garbage collection. | 217 // This function is not allowed to cause a garbage collection. |
| 219 // A GC might move the calling generated code and invalidate the | 218 // A GC might move the calling generated code and invalidate the |
| 220 // return address on the stack. | 219 // return address on the stack. |
| 221 ASSERT(byte_length % 2 == 0); | 220 ASSERT(byte_length % 2 == 0); |
| 222 uc16* substring1 = reinterpret_cast<uc16*>(byte_offset1); | 221 uc16* substring1 = reinterpret_cast<uc16*>(byte_offset1); |
| 223 uc16* substring2 = reinterpret_cast<uc16*>(byte_offset2); | 222 uc16* substring2 = reinterpret_cast<uc16*>(byte_offset2); |
| 224 size_t length = byte_length >> 1; | 223 size_t length = byte_length >> 1; |
| 225 | 224 |
| 226 for (size_t i = 0; i < length; i++) { | 225 for (size_t i = 0; i < length; i++) { |
| 227 unibrow::uchar c1 = substring1[i]; | 226 unibrow::uchar c1 = substring1[i]; |
| 228 unibrow::uchar c2 = substring2[i]; | 227 unibrow::uchar c2 = substring2[i]; |
| 229 if (c1 != c2) { | 228 if (c1 != c2) { |
| 230 unibrow::uchar s1[1] = { c1 }; | 229 unibrow::uchar s1[1] = { c1 }; |
| 231 canonicalize.get(c1, '\0', s1); | 230 canonicalize->get(c1, '\0', s1); |
| 232 if (s1[0] != c2) { | 231 if (s1[0] != c2) { |
| 233 unibrow::uchar s2[1] = { c2 }; | 232 unibrow::uchar s2[1] = { c2 }; |
| 234 canonicalize.get(c2, '\0', s2); | 233 canonicalize->get(c2, '\0', s2); |
| 235 if (s1[0] != s2[0]) { | 234 if (s1[0] != s2[0]) { |
| 236 return 0; | 235 return 0; |
| 237 } | 236 } |
| 238 } | 237 } |
| 239 } | 238 } |
| 240 } | 239 } |
| 241 return 1; | 240 return 1; |
| 242 } | 241 } |
| 243 | 242 |
| 244 | 243 |
| 245 Address NativeRegExpMacroAssembler::GrowStack(Address stack_pointer, | 244 Address NativeRegExpMacroAssembler::GrowStack(Address stack_pointer, |
| 246 Address* stack_base) { | 245 Address* stack_base) { |
| 247 size_t size = RegExpStack::stack_capacity(); | 246 size_t size = RegExpStack::stack_capacity(); |
| 248 Address old_stack_base = RegExpStack::stack_base(); | 247 Address old_stack_base = RegExpStack::stack_base(); |
| 249 ASSERT(old_stack_base == *stack_base); | 248 ASSERT(old_stack_base == *stack_base); |
| 250 ASSERT(stack_pointer <= old_stack_base); | 249 ASSERT(stack_pointer <= old_stack_base); |
| 251 ASSERT(static_cast<size_t>(old_stack_base - stack_pointer) <= size); | 250 ASSERT(static_cast<size_t>(old_stack_base - stack_pointer) <= size); |
| 252 Address new_stack_base = RegExpStack::EnsureCapacity(size * 2); | 251 Address new_stack_base = RegExpStack::EnsureCapacity(size * 2); |
| 253 if (new_stack_base == NULL) { | 252 if (new_stack_base == NULL) { |
| 254 return NULL; | 253 return NULL; |
| 255 } | 254 } |
| 256 *stack_base = new_stack_base; | 255 *stack_base = new_stack_base; |
| 257 intptr_t stack_content_size = old_stack_base - stack_pointer; | 256 intptr_t stack_content_size = old_stack_base - stack_pointer; |
| 258 return new_stack_base - stack_content_size; | 257 return new_stack_base - stack_content_size; |
| 259 } | 258 } |
| 260 | 259 |
| 261 #endif // V8_INTERPRETED_REGEXP | 260 #endif // V8_INTERPRETED_REGEXP |
| 262 | 261 |
| 263 } } // namespace v8::internal | 262 } } // namespace v8::internal |
| OLD | NEW |