libraries/v8/runtime.cc
// Copies ASCII characters to the given fixed array looking up
// one-char strings in the cache. Gives up on the first char that is
// not in the cache and fills the remainder with smi zeros. Returns
// the length of the successfully copied prefix.
Copies ASCII characters to the given fixed array looking up
one-char strings in the cache. Gives up on the first char that is
not in the cache and fills the remainder with smi zeros. Returns
the length of the successfully copied prefix.
Copies ASCII characters to the given fixed array looking up one - char strings in the cache . Gives up on the first char that is not in the cache and fills the remainder with smi zeros . Returns the length of the successfully copied prefix .
static int CopyCachedAsciiCharsToArray(Heap* heap,
                                       const uint8_t* chars,
                                       FixedArray* elements,
                                       int length) {
  DisallowHeapAllocation no_gc;
  FixedArray* ascii_cache = heap->single_character_string_cache();
  Object* undefined = heap->undefined_value();
  int i;
  WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc);
  for (i = 0; i < length; ++i) {
    Object* value = ascii_cache->get(chars[i]);
    if (value == undefined) break;
    elements->set(i, value, mode);
  }
  if (i < length) {
    ASSERT(Smi::FromInt(0) == 0);
    memset(elements->data_start() + i, 0, kPointerSize * (length - i));
  }
#ifdef DEBUG
  for (int j = 0; j < length; ++j) {
    Object* element = elements->get(j);
    ASSERT(element == Smi::FromInt(0) ||
           (element->IsString() && String::cast(element)->LooksValid()));
  }
#endif
  return i;
}
static int CopyCachedAsciiCharsToArray ( Heap * heap , const uint8_t * chars , FixedArray * elements , int length ) { DisallowHeapAllocation no_gc ; FixedArray * ascii_cache = heap -> single_character_string_cache ( ) ; Object * undefined = heap -> undefined_value ( ) ; int i ; WriteBarrierMode mode = elements -> GetWriteBarrierMode ( no_gc ) ; for ( i = 0 ; i < length ; ++ i ) { Object * value = ascii_cache -> get ( chars [ i ] ) ; if ( value == undefined ) break ; elements -> set ( i , value , mode ) ; } if ( i < length ) { ASSERT ( Smi :: FromInt ( 0 ) == 0 ) ; memset ( elements -> data_start ( ) + i , 0 , kPointerSize * ( length - i ) ) ; } #ifdef DEBUG for ( int j = 0 ; j < length ; ++ j ) { Object * element = elements -> get ( j ) ; ASSERT ( element == Smi :: FromInt ( 0 ) || ( element -> IsString ( ) && String :: cast ( element ) -> LooksValid ( ) ) ) ; } #endif return i ; }
Copies ASCII characters to the given fixed array looking up
one-char strings in the cache.
Copies ASCII characters to the given fixed array looking up one - char strings in the cache .