V8 Project
v8::internal::StringSharedKey Class Reference
+ Inheritance diagram for v8::internal::StringSharedKey:
+ Collaboration diagram for v8::internal::StringSharedKey:

Public Member Functions

 StringSharedKey (Handle< String > source, Handle< SharedFunctionInfo > shared, StrictMode strict_mode, int scope_position)
 
bool IsMatch (Object *other) OVERRIDE
 
uint32_t Hash () OVERRIDE
 
uint32_t HashForObject (Object *obj) OVERRIDE
 
Handle< ObjectAsHandle (Isolate *isolate) OVERRIDE
 
- Public Member Functions inherited from v8::internal::HashTableKey
virtual ~HashTableKey ()
 

Static Public Member Functions

static uint32_t StringSharedHashHelper (String *source, SharedFunctionInfo *shared, StrictMode strict_mode, int scope_position)
 

Private Attributes

Handle< Stringsource_
 
Handle< SharedFunctionInfoshared_
 
StrictMode strict_mode_
 
int scope_position_
 

Detailed Description

Definition at line 13554 of file objects.cc.

Constructor & Destructor Documentation

◆ StringSharedKey()

v8::internal::StringSharedKey::StringSharedKey ( Handle< String source,
Handle< SharedFunctionInfo shared,
StrictMode  strict_mode,
int  scope_position 
)
inline

Definition at line 13556 of file objects.cc.

13560  : source_(source),
13561  shared_(shared),
13562  strict_mode_(strict_mode),
13563  scope_position_(scope_position) { }
Handle< String > source_
Definition: objects.cc:13629
Handle< SharedFunctionInfo > shared_
Definition: objects.cc:13630

Member Function Documentation

◆ AsHandle()

Handle<Object> v8::internal::StringSharedKey::AsHandle ( Isolate isolate)
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 13619 of file objects.cc.

13619  {
13620  Handle<FixedArray> array = isolate->factory()->NewFixedArray(4);
13621  array->set(0, *shared_);
13622  array->set(1, *source_);
13623  array->set(2, Smi::FromInt(strict_mode_));
13624  array->set(3, Smi::FromInt(scope_position_));
13625  return array;
13626  }
static Smi * FromInt(int value)
Definition: objects-inl.h:1321

References v8::internal::Smi::FromInt().

Referenced by v8::internal::CompilationCacheTable::Put(), and v8::internal::CompilationCacheTable::PutEval().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Hash()

uint32_t v8::internal::StringSharedKey::Hash ( )
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 13600 of file objects.cc.

13600  {
13602  scope_position_);
13603  }
static uint32_t StringSharedHashHelper(String *source, SharedFunctionInfo *shared, StrictMode strict_mode, int scope_position)
Definition: objects.cc:13581

Referenced by v8::internal::CompilationCacheTable::Put(), and v8::internal::CompilationCacheTable::PutEval().

+ Here is the caller graph for this function:

◆ HashForObject()

uint32_t v8::internal::StringSharedKey::HashForObject ( Object obj)
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 13605 of file objects.cc.

13605  {
13606  DisallowHeapAllocation no_allocation;
13607  FixedArray* other_array = FixedArray::cast(obj);
13608  SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0));
13609  String* source = String::cast(other_array->get(1));
13610  int strict_unchecked = Smi::cast(other_array->get(2))->value();
13611  DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT);
13612  StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked);
13613  int scope_position = Smi::cast(other_array->get(3))->value();
13614  return StringSharedHashHelper(
13615  source, shared, strict_mode, scope_position);
13616  }
#define DCHECK(condition)
Definition: logging.h:205
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References DCHECK, v8::internal::FixedArray::get(), v8::internal::SLOPPY, and v8::internal::STRICT.

+ Here is the call graph for this function:

◆ IsMatch()

bool v8::internal::StringSharedKey::IsMatch ( Object other)
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 13565 of file objects.cc.

13565  {
13566  DisallowHeapAllocation no_allocation;
13567  if (!other->IsFixedArray()) return false;
13568  FixedArray* other_array = FixedArray::cast(other);
13569  SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0));
13570  if (shared != *shared_) return false;
13571  int strict_unchecked = Smi::cast(other_array->get(2))->value();
13572  DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT);
13573  StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked);
13574  if (strict_mode != strict_mode_) return false;
13575  int scope_position = Smi::cast(other_array->get(3))->value();
13576  if (scope_position != scope_position_) return false;
13577  String* source = String::cast(other_array->get(1));
13578  return source->Equals(*source_);
13579  }

References DCHECK, v8::internal::String::Equals(), v8::internal::FixedArray::get(), v8::internal::SLOPPY, and v8::internal::STRICT.

+ Here is the call graph for this function:

◆ StringSharedHashHelper()

static uint32_t v8::internal::StringSharedKey::StringSharedHashHelper ( String source,
SharedFunctionInfo shared,
StrictMode  strict_mode,
int  scope_position 
)
inlinestatic

Definition at line 13581 of file objects.cc.

13584  {
13585  uint32_t hash = source->Hash();
13586  if (shared->HasSourceCode()) {
13587  // Instead of using the SharedFunctionInfo pointer in the hash
13588  // code computation, we use a combination of the hash of the
13589  // script source code and the start position of the calling scope.
13590  // We do this to ensure that the cache entries can survive garbage
13591  // collection.
13592  Script* script(Script::cast(shared->script()));
13593  hash ^= String::cast(script->source())->Hash();
13594  if (strict_mode == STRICT) hash ^= 0x8000;
13595  hash += scope_position;
13596  }
13597  return hash;
13598  }

References v8::internal::Name::Hash(), v8::internal::SharedFunctionInfo::HasSourceCode(), and v8::internal::STRICT.

+ Here is the call graph for this function:

Member Data Documentation

◆ scope_position_

int v8::internal::StringSharedKey::scope_position_
private

Definition at line 13632 of file objects.cc.

◆ shared_

Handle<SharedFunctionInfo> v8::internal::StringSharedKey::shared_
private

Definition at line 13630 of file objects.cc.

◆ source_

Handle<String> v8::internal::StringSharedKey::source_
private

Definition at line 13629 of file objects.cc.

◆ strict_mode_

StrictMode v8::internal::StringSharedKey::strict_mode_
private

Definition at line 13631 of file objects.cc.


The documentation for this class was generated from the following file: