|
Lines 221-226
static const unsigned short typesOfASCIICharacters[128] = {
a/Source/JavaScriptCore/parser/Lexer.cpp_sec1
|
| 221 |
/* 127 - Delete */ CharacterInvalid, |
221 |
/* 127 - Delete */ CharacterInvalid, |
| 222 |
}; |
222 |
}; |
| 223 |
|
223 |
|
|
|
224 |
#if CPU(NEEDS_ALIGNED_ACCESS) |
| 225 |
|
| 226 |
#define COMPARE_CHARACTERS2(address, char1, char2) \ |
| 227 |
(((address)[0] == char1) && ((address)[1] == char2)) |
| 228 |
#define COMPARE_CHARACTERS4(address, char1, char2, char3, char4) \ |
| 229 |
(COMPARE_CHARACTERS2(address, char1, char2) && COMPARE_CHARACTERS2((address) + 2, char3, char4)) |
| 230 |
|
| 231 |
#else |
| 232 |
|
| 233 |
#if CPU(BIG_ENDIAN) |
| 234 |
#define CHARPAIR_TOUINT32(a, b) ((((uint32_t)(a)) << 16) + (uint32_t)(b)) |
| 235 |
#define CHARQUAD_TOUINT64(a, b, c, d) ((((uint64_t)(CHARPAIR_TOUINT32(a, b))) << 32) + CHARPAIR_TOUINT32(c, d)) |
| 236 |
#else |
| 237 |
#define CHARPAIR_TOUINT32(a, b) ((((uint32_t)(b)) << 16) + (uint32_t)(a)) |
| 238 |
#define CHARQUAD_TOUINT64(a, b, c, d) ((((uint64_t)(CHARPAIR_TOUINT32(c, d))) << 32) + CHARPAIR_TOUINT32(a, b)) |
| 239 |
#endif |
| 240 |
|
| 241 |
#define COMPARE_CHARACTERS2(address, char1, char2) \ |
| 242 |
(((uint32_t*)(address))[0] == CHARPAIR_TOUINT32(char1, char2)) |
| 243 |
#if CPU(X86_64) |
| 244 |
|
| 245 |
#define COMPARE_CHARACTERS4(address, char1, char2, char3, char4) \ |
| 246 |
(((uint64_t*)(address))[0] == CHARQUAD_TOUINT64(char1, char2, char3, char4)) |
| 247 |
#else |
| 248 |
#define COMPARE_CHARACTERS4(address, char1, char2, char3, char4) \ |
| 249 |
(COMPARE_CHARACTERS2(address, char1, char2) && COMPARE_CHARACTERS2((address) + 2, char3, char4)) |
| 250 |
#endif |
| 251 |
|
| 252 |
#endif |
| 253 |
|
| 254 |
#define COMPARE_CHARACTERS3(address, char1, char2, char3) \ |
| 255 |
(COMPARE_CHARACTERS2(address, char1, char2) && ((address)[2] == (char3))) |
| 256 |
#define COMPARE_CHARACTERS5(address, char1, char2, char3, char4, char5) \ |
| 257 |
(COMPARE_CHARACTERS4(address, char1, char2, char3, char4) && ((address)[4] == (char5))) |
| 258 |
#define COMPARE_CHARACTERS6(address, char1, char2, char3, char4, char5, char6) \ |
| 259 |
(COMPARE_CHARACTERS4(address, char1, char2, char3, char4) && COMPARE_CHARACTERS2(address + 4, char5, char6)) |
| 260 |
#define COMPARE_CHARACTERS8(address, char1, char2, char3, char4, char5, char6, char7, char8) \ |
| 261 |
(COMPARE_CHARACTERS4(address, char1, char2, char3, char4) && COMPARE_CHARACTERS4(address + 4, char5, char6, char7, char8)) |
| 262 |
|
| 263 |
|
| 224 |
Lexer::Lexer(JSGlobalData* globalData) |
264 |
Lexer::Lexer(JSGlobalData* globalData) |
| 225 |
: m_isReparsing(false) |
265 |
: m_isReparsing(false) |
| 226 |
, m_globalData(globalData) |
266 |
, m_globalData(globalData) |
|
Lines 271-284
void Lexer::setCode(const SourceCode& source, ParserArena& arena)
a/Source/JavaScriptCore/parser/Lexer.cpp_sec2
|
| 271 |
ASSERT(currentOffset() == source.startOffset()); |
311 |
ASSERT(currentOffset() == source.startOffset()); |
| 272 |
} |
312 |
} |
| 273 |
|
313 |
|
| 274 |
ALWAYS_INLINE void Lexer::shift() |
314 |
template <int shiftAmount, bool shouldBoundsCheck> ALWAYS_INLINE void Lexer::internalShift() |
| 275 |
{ |
315 |
{ |
| 276 |
// Faster than an if-else sequence |
316 |
if (shouldBoundsCheck) { |
| 277 |
ASSERT(m_current != -1); |
317 |
// Faster than an if-else sequence |
| 278 |
m_current = -1; |
318 |
ASSERT(m_current != -1); |
| 279 |
++m_code; |
319 |
m_current = -1; |
| 280 |
if (LIKELY(m_code < m_codeEnd)) |
320 |
m_code += shiftAmount; |
|
|
321 |
if (LIKELY(m_code < m_codeEnd)) |
| 322 |
m_current = *m_code; |
| 323 |
} else { |
| 324 |
m_code += shiftAmount; |
| 281 |
m_current = *m_code; |
325 |
m_current = *m_code; |
|
|
326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
ALWAYS_INLINE void Lexer::shift() |
| 330 |
{ |
| 331 |
internalShift<1, true>(); |
| 282 |
} |
332 |
} |
| 283 |
|
333 |
|
| 284 |
ALWAYS_INLINE int Lexer::peek(int offset) |
334 |
ALWAYS_INLINE int Lexer::peek(int offset) |
|
Lines 401-409
inline void Lexer::record16(int c)
a/Source/JavaScriptCore/parser/Lexer.cpp_sec3
|
| 401 |
|
451 |
|
| 402 |
template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer::parseIdentifier(JSTokenData* lvalp, unsigned lexType) |
452 |
template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer::parseIdentifier(JSTokenData* lvalp, unsigned lexType) |
| 403 |
{ |
453 |
{ |
| 404 |
bool bufferRequired = false; |
454 |
|
|
|
455 |
#include "KeywordLookup.h" |
| 456 |
|
| 405 |
const UChar* identifierStart = currentCharacter(); |
457 |
const UChar* identifierStart = currentCharacter(); |
| 406 |
int identifierLength; |
458 |
bool bufferRequired = false; |
| 407 |
|
459 |
|
| 408 |
while (true) { |
460 |
while (true) { |
| 409 |
if (LIKELY(isIdentPart(m_current))) { |
461 |
if (LIKELY(isIdentPart(m_current))) { |
|
Lines 430-436
template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer::parseIde
a/Source/JavaScriptCore/parser/Lexer.cpp_sec4
|
| 430 |
record16(character); |
482 |
record16(character); |
| 431 |
identifierStart = currentCharacter(); |
483 |
identifierStart = currentCharacter(); |
| 432 |
} |
484 |
} |
| 433 |
|
485 |
|
|
|
486 |
int identifierLength; |
| 434 |
const Identifier* ident = 0; |
487 |
const Identifier* ident = 0; |
| 435 |
if (shouldCreateIdentifier) { |
488 |
if (shouldCreateIdentifier) { |
| 436 |
if (!bufferRequired) |
489 |
if (!bufferRequired) |
|
Lines 452-459
template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer::parseIde
a/Source/JavaScriptCore/parser/Lexer.cpp_sec5
|
| 452 |
if (LIKELY(!bufferRequired && !(lexType & IgnoreReservedWords))) { |
505 |
if (LIKELY(!bufferRequired && !(lexType & IgnoreReservedWords))) { |
| 453 |
ASSERT(shouldCreateIdentifier); |
506 |
ASSERT(shouldCreateIdentifier); |
| 454 |
// Keywords must not be recognized if there was an \uXXXX in the identifier. |
507 |
// Keywords must not be recognized if there was an \uXXXX in the identifier. |
| 455 |
const HashEntry* entry = m_keywordTable.entry(m_globalData, *ident); |
508 |
if (remaining < maxTokenLength) { |
| 456 |
return entry ? static_cast<JSTokenType>(entry->lexerValue()) : IDENT; |
509 |
const HashEntry* entry = m_keywordTable.entry(m_globalData, *ident); |
|
|
510 |
ASSERT((remaining < maxTokenLength) || !entry); |
| 511 |
return entry ? static_cast<JSTokenType>(entry->lexerValue()) : IDENT; |
| 512 |
} |
| 513 |
return IDENT; |
| 457 |
} |
514 |
} |
| 458 |
|
515 |
|
| 459 |
m_buffer16.resize(0); |
516 |
m_buffer16.resize(0); |