V8 Project
v8::internal::Runtime Class Reference

#include <runtime.h>

+ Inheritance diagram for v8::internal::Runtime:
+ Collaboration diagram for v8::internal::Runtime:

Classes

struct  Function
 

Public Types

enum  FunctionId { RUNTIME_FUNCTION_LIST , kFirstInlineFunction = kInlineIsSmi }
 
enum  IntrinsicType { RUNTIME , INLINE , INLINE_OPTIMIZED }
 
enum  TypedArrayId {
  ARRAY_ID_UINT8 = 1 , ARRAY_ID_INT8 = 2 , ARRAY_ID_UINT16 = 3 , ARRAY_ID_INT16 = 4 ,
  ARRAY_ID_UINT32 = 5 , ARRAY_ID_INT32 = 6 , ARRAY_ID_FLOAT32 = 7 , ARRAY_ID_FLOAT64 = 8 ,
  ARRAY_ID_UINT8_CLAMPED = 9 , ARRAY_ID_FIRST = ARRAY_ID_UINT8 , ARRAY_ID_LAST = ARRAY_ID_UINT8_CLAMPED
}
 

Static Public Member Functions

static void InitializeIntrinsicFunctionNames (Isolate *isolate, Handle< NameDictionary > dict)
 
static const FunctionFunctionForName (Handle< String > name)
 
static const FunctionFunctionForId (FunctionId id)
 
static const FunctionFunctionForEntry (Address ref)
 
static int StringMatch (Isolate *isolate, Handle< String > sub, Handle< String > pat, int index)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElementOrCharAt (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetObjectProperty (Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, StrictMode strict_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectDefineObjectProperty (Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
 
static MUST_USE_RESULT MaybeHandle< ObjectDeleteObjectProperty (Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key, JSReceiver::DeleteMode mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectHasObjectProperty (Isolate *isolate, Handle< JSReceiver > object, Handle< Object > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetObjectProperty (Isolate *isolate, Handle< Object > object, Handle< Object > key)
 
static void SetupArrayBuffer (Isolate *isolate, Handle< JSArrayBuffer > array_buffer, bool is_external, void *data, size_t allocated_length)
 
static bool SetupArrayBufferAllocatingData (Isolate *isolate, Handle< JSArrayBuffer > array_buffer, size_t allocated_length, bool initialize=true)
 
static void NeuterArrayBuffer (Handle< JSArrayBuffer > array_buffer)
 
static void FreeArrayBuffer (Isolate *isolate, JSArrayBuffer *phantom_array_buffer)
 
static void ArrayIdToTypeAndSize (int array_id, ExternalArrayType *type, ElementsKind *external_elements_kind, ElementsKind *fixed_elements_kind, size_t *element_size)
 
static MUST_USE_RESULT MaybeHandle< ObjectCreateArrayLiteralBoilerplate (Isolate *isolate, Handle< FixedArray > literals, Handle< FixedArray > elements)
 

Static Public Attributes

static const int kNotFound = -1
 

Detailed Description

Definition at line 772 of file runtime.h.

Member Enumeration Documentation

◆ FunctionId

Enumerator
RUNTIME_FUNCTION_LIST 
kFirstInlineFunction 

Definition at line 774 of file runtime.h.

774  {
775 #define F(name, nargs, ressize) k##name,
777 #undef F
778 #define F(name, nargs, ressize) kInline##name,
780 #undef F
781 #define F(name, nargs, ressize) kInlineOptimized##name,
783 #undef F
784  kNumFunctions,
785  kFirstInlineFunction = kInlineIsSmi
786  };
#define INLINE_OPTIMIZED_FUNCTION_LIST(F)
Definition: runtime.h:708
#define INLINE_FUNCTION_LIST(F)
Definition: runtime.h:659

◆ IntrinsicType

Enumerator
RUNTIME 
INLINE 
INLINE_OPTIMIZED 

Definition at line 788 of file runtime.h.

◆ TypedArrayId

Enumerator
ARRAY_ID_UINT8 
ARRAY_ID_INT8 
ARRAY_ID_UINT16 
ARRAY_ID_INT16 
ARRAY_ID_UINT32 
ARRAY_ID_INT32 
ARRAY_ID_FLOAT32 
ARRAY_ID_FLOAT64 
ARRAY_ID_UINT8_CLAMPED 
ARRAY_ID_FIRST 
ARRAY_ID_LAST 

Definition at line 868 of file runtime.h.

868  {
869  // arrayIds below should be synchromized with typedarray.js natives.
870  ARRAY_ID_UINT8 = 1,
871  ARRAY_ID_INT8 = 2,
872  ARRAY_ID_UINT16 = 3,
873  ARRAY_ID_INT16 = 4,
874  ARRAY_ID_UINT32 = 5,
875  ARRAY_ID_INT32 = 6,
876  ARRAY_ID_FLOAT32 = 7,
877  ARRAY_ID_FLOAT64 = 8,
881  };

Member Function Documentation

◆ ArrayIdToTypeAndSize()

void v8::internal::Runtime::ArrayIdToTypeAndSize ( int  array_id,
ExternalArrayType type,
ElementsKind external_elements_kind,
ElementsKind fixed_elements_kind,
size_t *  element_size 
)
static

Definition at line 186 of file runtime-typedarray.cc.

189  {
190  switch (arrayId) {
191 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \
192  case ARRAY_ID_##TYPE: \
193  *array_type = kExternal##Type##Array; \
194  *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \
195  *fixed_elements_kind = TYPE##_ELEMENTS; \
196  *element_size = size; \
197  break;
198 
200 #undef ARRAY_ID_CASE
201 
202  default:
203  UNREACHABLE();
204  }
205 }
#define UNREACHABLE()
Definition: logging.h:30
#define TYPED_ARRAYS(V)
Definition: objects.h:4433
#define ARRAY_ID_CASE(Type, type, TYPE, ctype, size)

References ARRAY_ID_CASE, TYPED_ARRAYS, and UNREACHABLE.

Referenced by v8::internal::RUNTIME_FUNCTION().

+ Here is the caller graph for this function:

◆ CreateArrayLiteralBoilerplate()

MaybeHandle< Object > v8::internal::Runtime::CreateArrayLiteralBoilerplate ( Isolate isolate,
Handle< FixedArray literals,
Handle< FixedArray elements 
)
static

Definition at line 248 of file runtime.cc.

250  {
251  // Create the JSArray.
252  Handle<JSFunction> constructor(
253  JSFunction::NativeContextFromLiterals(*literals)->array_function());
254 
255  PretenureFlag pretenure_flag =
256  isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
257 
258  Handle<JSArray> object = Handle<JSArray>::cast(
259  isolate->factory()->NewJSObject(constructor, pretenure_flag));
260 
261  ElementsKind constant_elements_kind =
262  static_cast<ElementsKind>(Smi::cast(elements->get(0))->value());
263  Handle<FixedArrayBase> constant_elements_values(
264  FixedArrayBase::cast(elements->get(1)));
265 
266  {
268  DCHECK(IsFastElementsKind(constant_elements_kind));
269  Context* native_context = isolate->context()->native_context();
270  Object* maps_array = native_context->js_array_maps();
271  DCHECK(!maps_array->IsUndefined());
272  Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind);
273  object->set_map(Map::cast(map));
274  }
275 
276  Handle<FixedArrayBase> copied_elements_values;
277  if (IsFastDoubleElementsKind(constant_elements_kind)) {
278  copied_elements_values = isolate->factory()->CopyFixedDoubleArray(
279  Handle<FixedDoubleArray>::cast(constant_elements_values));
280  } else {
281  DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind));
282  const bool is_cow = (constant_elements_values->map() ==
283  isolate->heap()->fixed_cow_array_map());
284  if (is_cow) {
285  copied_elements_values = constant_elements_values;
286 #if DEBUG
287  Handle<FixedArray> fixed_array_values =
288  Handle<FixedArray>::cast(copied_elements_values);
289  for (int i = 0; i < fixed_array_values->length(); i++) {
290  DCHECK(!fixed_array_values->get(i)->IsFixedArray());
291  }
292 #endif
293  } else {
294  Handle<FixedArray> fixed_array_values =
295  Handle<FixedArray>::cast(constant_elements_values);
296  Handle<FixedArray> fixed_array_values_copy =
297  isolate->factory()->CopyFixedArray(fixed_array_values);
298  copied_elements_values = fixed_array_values_copy;
299  for (int i = 0; i < fixed_array_values->length(); i++) {
300  if (fixed_array_values->get(i)->IsFixedArray()) {
301  // The value contains the constant_properties of a
302  // simple object or array literal.
303  Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i)));
304  Handle<Object> result;
306  isolate, result, CreateLiteralBoilerplate(isolate, literals, fa),
307  Object);
308  fixed_array_values_copy->set(i, *result);
309  }
310  }
311  }
312  }
313  object->set_elements(*copied_elements_values);
314  object->set_length(Smi::FromInt(copied_elements_values->length()));
315 
317  return object;
318 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static Context * NativeContextFromLiterals(FixedArray *literals)
Definition: objects.cc:9554
static void ValidateElements(Handle< JSObject > object)
Definition: objects-inl.h:1561
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
enable harmony numeric literals(0o77, 0b11)") DEFINE_BOOL(harmony_object_literals
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
Definition: isolate.h:135
#define DCHECK(condition)
Definition: logging.h:205
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
kSerializedDataOffset Object
Definition: objects-inl.h:5322
bool IsFastDoubleElementsKind(ElementsKind kind)
static MUST_USE_RESULT MaybeHandle< Object > CreateLiteralBoilerplate(Isolate *isolate, Handle< FixedArray > literals, Handle< FixedArray > constant_properties)
Definition: runtime.cc:321
bool IsFastElementsKind(ElementsKind kind)

References ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Handle< T >::cast(), v8::internal::Isolate::context(), v8::internal::CreateLiteralBoilerplate(), DCHECK, v8::internal::Isolate::factory(), v8::internal::Smi::FromInt(), v8::internal::Isolate::heap(), v8::internal::Heap::InNewSpace(), v8::internal::IsFastDoubleElementsKind(), v8::internal::IsFastElementsKind(), v8::internal::IsFastSmiOrObjectElementsKind(), literals(), map, v8::internal::Context::native_context(), v8::internal::JSFunction::NativeContextFromLiterals(), v8::internal::NOT_TENURED, v8::internal::TENURED, and v8::internal::JSObject::ValidateElements().

Referenced by v8::internal::CreateLiteralBoilerplate(), and v8::internal::GetLiteralAllocationSite().

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

◆ DefineObjectProperty()

MaybeHandle< Object > v8::internal::Runtime::DefineObjectProperty ( Handle< JSObject object,
Handle< Object key,
Handle< Object value,
PropertyAttributes  attr 
)
static

Definition at line 2277 of file runtime.cc.

2280  {
2281  Isolate* isolate = js_object->GetIsolate();
2282  // Check if the given key is an array index.
2283  uint32_t index;
2284  if (key->ToArrayIndex(&index)) {
2285  // In Firefox/SpiderMonkey, Safari and Opera you can access the characters
2286  // of a string using [] notation. We need to support this too in
2287  // JavaScript.
2288  // In the case of a String object we just need to redirect the assignment to
2289  // the underlying string if the index is in range. Since the underlying
2290  // string does nothing with the assignment then we can ignore such
2291  // assignments.
2292  if (js_object->IsStringObjectWithCharacterAt(index)) {
2293  return value;
2294  }
2295 
2296  return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false,
2297  DEFINE_PROPERTY);
2298  }
2299 
2300  if (key->IsName()) {
2301  Handle<Name> name = Handle<Name>::cast(key);
2302  if (name->AsArrayIndex(&index)) {
2303  return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false,
2304  DEFINE_PROPERTY);
2305  } else {
2306  if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
2307  return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
2308  attr);
2309  }
2310  }
2311 
2312  // Call-back into JavaScript to convert the key to a string.
2313  Handle<Object> converted;
2314  ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
2315  Execution::ToString(isolate, key), Object);
2316  Handle<String> name = Handle<String>::cast(converted);
2317 
2318  if (name->AsArrayIndex(&index)) {
2319  return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false,
2320  DEFINE_PROPERTY);
2321  } else {
2322  return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
2323  attr);
2324  }
2325 }
static MUST_USE_RESULT MaybeHandle< Object > SetElement(Handle< JSObject > object, uint32_t index, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, bool check_prototype=true, SetPropertyMode set_mode=SET_PROPERTY)
Definition: objects.cc:12336
static MUST_USE_RESULT MaybeHandle< Object > SetOwnPropertyIgnoreAttributes(Handle< JSObject > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, ExecutableAccessorInfoHandling handling=DEFAULT_HANDLING)
Definition: objects.cc:3808
static Handle< String > Flatten(Handle< String > string, PretenureFlag pretenure=NOT_TENURED)
Definition: objects-inl.h:3354
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
@ DEFINE_PROPERTY
Definition: objects.h:1552

References ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Handle< T >::cast(), v8::internal::DEFINE_PROPERTY, v8::internal::String::Flatten(), name, v8::internal::JSObject::SetElement(), v8::internal::JSObject::SetOwnPropertyIgnoreAttributes(), and v8::internal::SLOPPY.

Referenced by v8::internal::ScopeInfo::CopyContextLocalsToScopeObject(), v8::Object::ForceSet(), v8::internal::MaterializeArgumentsObject(), v8::internal::MaterializeCatchScope(), v8::internal::MaterializeClosure(), v8::internal::RUNTIME_FUNCTION(), and v8::internal::SetClosureVariableValue().

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

◆ DeleteObjectProperty()

MaybeHandle< Object > v8::internal::Runtime::DeleteObjectProperty ( Isolate isolate,
Handle< JSReceiver object,
Handle< Object key,
JSReceiver::DeleteMode  mode 
)
static

Definition at line 2328 of file runtime.cc.

2331  {
2332  // Check if the given key is an array index.
2333  uint32_t index;
2334  if (key->ToArrayIndex(&index)) {
2335  // In Firefox/SpiderMonkey, Safari and Opera you can access the
2336  // characters of a string using [] notation. In the case of a
2337  // String object we just need to redirect the deletion to the
2338  // underlying string if the index is in range. Since the
2339  // underlying string does nothing with the deletion, we can ignore
2340  // such deletions.
2341  if (receiver->IsStringObjectWithCharacterAt(index)) {
2342  return isolate->factory()->true_value();
2343  }
2344 
2345  return JSReceiver::DeleteElement(receiver, index, mode);
2346  }
2347 
2348  Handle<Name> name;
2349  if (key->IsName()) {
2350  name = Handle<Name>::cast(key);
2351  } else {
2352  // Call-back into JavaScript to convert the key to a string.
2353  Handle<Object> converted;
2354  ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
2355  Execution::ToString(isolate, key), Object);
2356  name = Handle<String>::cast(converted);
2357  }
2358 
2359  if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
2360  return JSReceiver::DeleteProperty(receiver, name, mode);
2361 }
static MUST_USE_RESULT MaybeHandle< Object > DeleteElement(Handle< JSReceiver > object, uint32_t index, DeleteMode mode=NORMAL_DELETION)
Definition: objects.cc:5002
static MUST_USE_RESULT MaybeHandle< Object > DeleteProperty(Handle< JSReceiver > object, Handle< Name > name, DeleteMode mode=NORMAL_DELETION)
Definition: objects.cc:5013
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp

References ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Handle< T >::cast(), v8::internal::JSReceiver::DeleteElement(), v8::internal::JSReceiver::DeleteProperty(), v8::internal::Isolate::factory(), v8::internal::String::Flatten(), mode(), and name.

Referenced by v8::Object::Delete(), and v8::Object::ForceDelete().

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

◆ FreeArrayBuffer()

void v8::internal::Runtime::FreeArrayBuffer ( Isolate isolate,
JSArrayBuffer phantom_array_buffer 
)
static

Definition at line 15 of file runtime-typedarray.cc.

16  {
17  if (phantom_array_buffer->should_be_freed()) {
18  DCHECK(phantom_array_buffer->is_external());
19  free(phantom_array_buffer->backing_store());
20  }
21  if (phantom_array_buffer->is_external()) return;
22 
23  size_t allocated_length =
24  NumberToSize(isolate, phantom_array_buffer->byte_length());
25 
26  reinterpret_cast<v8::Isolate*>(isolate)
27  ->AdjustAmountOfExternalAllocatedMemory(
28  -static_cast<int64_t>(allocated_length));
30  V8::ArrayBufferAllocator()->Free(phantom_array_buffer->backing_store(),
31  allocated_length);
32 }
virtual void Free(void *data, size_t length)=0
Free the memory block of size |length|, pointed to by |data|.
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
static v8::ArrayBuffer::Allocator * ArrayBufferAllocator()
Definition: v8.h:72
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define CHECK(condition)
Definition: logging.h:36
size_t NumberToSize(Isolate *isolate, Object *number)
Definition: conversions.h:233

References v8::internal::V8::ArrayBufferAllocator(), CHECK, DCHECK, v8::ArrayBuffer::Allocator::Free(), v8::internal::JSArrayBuffer::is_external(), NULL, v8::internal::NumberToSize(), and v8::internal::JSArrayBuffer::should_be_freed().

Referenced by v8::internal::Heap::TearDownArrayBuffers(), and v8::internal::WeakListVisitor< JSArrayBuffer >::VisitPhantomObject().

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

◆ FunctionForEntry()

const Runtime::Function * v8::internal::Runtime::FunctionForEntry ( Address  ref)
static

Definition at line 9302 of file runtime.cc.

9302  {
9303  for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) {
9304  if (entry == kIntrinsicFunctions[i].entry) {
9305  return &(kIntrinsicFunctions[i]);
9306  }
9307  }
9308  return NULL;
9309 }
#define arraysize(array)
Definition: macros.h:86
static const Runtime::Function kIntrinsicFunctions[]
Definition: runtime.cc:9264

References arraysize, v8::internal::kIntrinsicFunctions, and NULL.

Referenced by v8::internal::compiler::StaticParameterTraits< ExternalReference >::PrintTo().

+ Here is the caller graph for this function:

◆ FunctionForId()

◆ FunctionForName()

const Runtime::Function * v8::internal::Runtime::FunctionForName ( Handle< String name)
static

Definition at line 9290 of file runtime.cc.

9290  {
9291  Heap* heap = name->GetHeap();
9292  int entry = heap->intrinsic_function_names()->FindEntry(name);
9293  if (entry != kNotFound) {
9294  Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
9295  int function_index = Smi::cast(smi_index)->value();
9296  return &(kIntrinsicFunctions[function_index]);
9297  }
9298  return NULL;
9299 }
static const int kNotFound
Definition: runtime.h:807

References v8::internal::kIntrinsicFunctions, kNotFound, name, and NULL.

Referenced by v8::internal::Parser::ParseV8Intrinsic().

+ Here is the caller graph for this function:

◆ GetElementOrCharAt()

MaybeHandle< Object > v8::internal::Runtime::GetElementOrCharAt ( Isolate isolate,
Handle< Object object,
uint32_t  index 
)
static

Definition at line 1850 of file runtime.cc.

1852  {
1853  // Handle [] indexing on Strings
1854  if (object->IsString()) {
1855  Handle<Object> result = GetCharAt(Handle<String>::cast(object), index);
1856  if (!result->IsUndefined()) return result;
1857  }
1858 
1859  // Handle [] indexing on String objects
1860  if (object->IsStringObjectWithCharacterAt(index)) {
1861  Handle<JSValue> js_value = Handle<JSValue>::cast(object);
1862  Handle<Object> result =
1863  GetCharAt(Handle<String>(String::cast(js_value->value())), index);
1864  if (!result->IsUndefined()) return result;
1865  }
1866 
1867  Handle<Object> result;
1868  if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
1869  PrototypeIterator iter(isolate, object);
1870  return Object::GetElement(isolate, PrototypeIterator::GetCurrent(iter),
1871  index);
1872  } else {
1873  return Object::GetElement(isolate, object, index);
1874  }
1875 }
static MUST_USE_RESULT MaybeHandle< Object > GetElement(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: objects-inl.h:1113
Object * GetCurrent() const
Definition: prototype.h:62
static Handle< Object > GetCharAt(Handle< String > string, uint32_t index)
Definition: runtime.cc:1840

References v8::internal::Handle< T >::cast(), v8::internal::GetCharAt(), v8::internal::PrototypeIterator::GetCurrent(), and v8::internal::Object::GetElement().

Referenced by GetObjectProperty(), v8::internal::GetOwnProperty(), v8::internal::LoadIC::Load(), and v8::internal::RUNTIME_FUNCTION().

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

◆ GetObjectProperty()

MaybeHandle< Object > v8::internal::Runtime::GetObjectProperty ( Isolate isolate,
Handle< Object object,
Handle< Object key 
)
static

Definition at line 1912 of file runtime.cc.

1914  {
1915  if (object->IsUndefined() || object->IsNull()) {
1916  Handle<Object> args[2] = {key, object};
1917  THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_load",
1918  HandleVector(args, 2)),
1919  Object);
1920  }
1921 
1922  // Check if the given key is an array index.
1923  uint32_t index;
1924  if (key->ToArrayIndex(&index)) {
1925  return GetElementOrCharAt(isolate, object, index);
1926  }
1927 
1928  // Convert the key to a name - possibly by calling back into JavaScript.
1929  Handle<Name> name;
1930  ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object);
1931 
1932  // Check if the name is trivially convertible to an index and get
1933  // the element if so.
1934  if (name->AsArrayIndex(&index)) {
1935  return GetElementOrCharAt(isolate, object, index);
1936  } else {
1937  return Object::GetProperty(object, name);
1938  }
1939 }
static MUST_USE_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it)
Definition: objects.cc:109
static MUST_USE_RESULT MaybeHandle< Object > GetElementOrCharAt(Isolate *isolate, Handle< Object > object, uint32_t index)
Definition: runtime.cc:1850
#define THROW_NEW_ERROR(isolate, call, T)
Definition: isolate.h:138
static MUST_USE_RESULT MaybeHandle< Name > ToName(Isolate *isolate, Handle< Object > key)
Definition: runtime.cc:1879
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
Definition: utils.h:1100

References ASSIGN_RETURN_ON_EXCEPTION, GetElementOrCharAt(), v8::internal::Object::GetProperty(), v8::internal::HandleVector(), name, THROW_NEW_ERROR, and v8::internal::ToName().

Referenced by v8::Object::Get(), v8::internal::KeyedLoadIC::Load(), and v8::internal::RUNTIME_FUNCTION().

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

◆ HasObjectProperty()

MaybeHandle< Object > v8::internal::Runtime::HasObjectProperty ( Isolate isolate,
Handle< JSReceiver object,
Handle< Object key 
)
static

Definition at line 1891 of file runtime.cc.

1893  {
1894  Maybe<bool> maybe;
1895  // Check if the given key is an array index.
1896  uint32_t index;
1897  if (key->ToArrayIndex(&index)) {
1898  maybe = JSReceiver::HasElement(object, index);
1899  } else {
1900  // Convert the key to a name - possibly by calling back into JavaScript.
1901  Handle<Name> name;
1902  ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object);
1903 
1904  maybe = JSReceiver::HasProperty(object, name);
1905  }
1906 
1907  if (!maybe.has_value) return MaybeHandle<Object>();
1908  return isolate->factory()->ToBoolean(maybe.value);
1909 }
static MUST_USE_RESULT Maybe< bool > HasElement(Handle< JSReceiver > object, uint32_t index)
Definition: objects-inl.h:6718
static MUST_USE_RESULT Maybe< bool > HasProperty(Handle< JSReceiver > object, Handle< Name > name)
Definition: objects-inl.h:6646
Maybe< T > maybe(T t)
Definition: v8.h:902

References ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Isolate::factory(), v8::internal::JSReceiver::HasElement(), v8::internal::JSReceiver::HasProperty(), v8::maybe(), name, and v8::internal::ToName().

Referenced by v8::Object::Has().

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

◆ InitializeIntrinsicFunctionNames()

void v8::internal::Runtime::InitializeIntrinsicFunctionNames ( Isolate isolate,
Handle< NameDictionary dict 
)
static

Definition at line 9273 of file runtime.cc.

9274  {
9275  DCHECK(dict->NumberOfElements() == 0);
9276  HandleScope scope(isolate);
9277  for (int i = 0; i < kNumFunctions; ++i) {
9278  const char* name = kIntrinsicFunctions[i].name;
9279  if (name == NULL) continue;
9280  Handle<NameDictionary> new_dict = NameDictionary::Add(
9281  dict, isolate->factory()->InternalizeUtf8String(name),
9282  Handle<Smi>(Smi::FromInt(i), isolate),
9283  PropertyDetails(NONE, NORMAL, Representation::None()));
9284  // The dictionary does not need to grow.
9285  CHECK(new_dict.is_identical_to(dict));
9286  }
9287 }
static MUST_USE_RESULT Handle< NameDictionary > Add(Handle< NameDictionary > dictionary, Handle< Name > key, Handle< Object > value, PropertyDetails details)
Definition: objects.cc:15024
static Representation None()
@ NONE

References v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >::Add(), CHECK, DCHECK, v8::internal::Isolate::factory(), v8::internal::Smi::FromInt(), v8::internal::kIntrinsicFunctions, name, v8::internal::Runtime::Function::name, NONE, v8::internal::Representation::None(), v8::internal::NORMAL, and NULL.

Referenced by v8::internal::Heap::CreateInitialObjects().

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

◆ NeuterArrayBuffer()

void v8::internal::Runtime::NeuterArrayBuffer ( Handle< JSArrayBuffer array_buffer)
static

Definition at line 86 of file runtime-typedarray.cc.

86  {
87  Isolate* isolate = array_buffer->GetIsolate();
88  for (Handle<Object> view_obj(array_buffer->weak_first_view(), isolate);
89  !view_obj->IsUndefined();) {
90  Handle<JSArrayBufferView> view(JSArrayBufferView::cast(*view_obj));
91  if (view->IsJSTypedArray()) {
92  JSTypedArray::cast(*view)->Neuter();
93  } else if (view->IsJSDataView()) {
94  JSDataView::cast(*view)->Neuter();
95  } else {
96  UNREACHABLE();
97  }
98  view_obj = handle(view->weak_next(), isolate);
99  }
100  array_buffer->Neuter();
101 }
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::handle(), and UNREACHABLE.

Referenced by v8::ArrayBuffer::Neuter(), and v8::internal::RUNTIME_FUNCTION().

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

◆ SetObjectProperty()

MaybeHandle< Object > v8::internal::Runtime::SetObjectProperty ( Isolate isolate,
Handle< Object object,
Handle< Object key,
Handle< Object value,
StrictMode  strict_mode 
)
static

Definition at line 2181 of file runtime.cc.

2185  {
2186  if (object->IsUndefined() || object->IsNull()) {
2187  Handle<Object> args[2] = {key, object};
2188  THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store",
2189  HandleVector(args, 2)),
2190  Object);
2191  }
2192 
2193  if (object->IsJSProxy()) {
2194  Handle<Object> name_object;
2195  if (key->IsSymbol()) {
2196  name_object = key;
2197  } else {
2198  ASSIGN_RETURN_ON_EXCEPTION(isolate, name_object,
2199  Execution::ToString(isolate, key), Object);
2200  }
2201  Handle<Name> name = Handle<Name>::cast(name_object);
2202  return Object::SetProperty(Handle<JSProxy>::cast(object), name, value,
2203  strict_mode);
2204  }
2205 
2206  // Check if the given key is an array index.
2207  uint32_t index;
2208  if (key->ToArrayIndex(&index)) {
2209  // TODO(verwaest): Support non-JSObject receivers.
2210  if (!object->IsJSObject()) return value;
2211  Handle<JSObject> js_object = Handle<JSObject>::cast(object);
2212 
2213  // In Firefox/SpiderMonkey, Safari and Opera you can access the characters
2214  // of a string using [] notation. We need to support this too in
2215  // JavaScript.
2216  // In the case of a String object we just need to redirect the assignment to
2217  // the underlying string if the index is in range. Since the underlying
2218  // string does nothing with the assignment then we can ignore such
2219  // assignments.
2220  if (js_object->IsStringObjectWithCharacterAt(index)) {
2221  return value;
2222  }
2223 
2224  JSObject::ValidateElements(js_object);
2225  if (js_object->HasExternalArrayElements() ||
2226  js_object->HasFixedTypedArrayElements()) {
2227  if (!value->IsNumber() && !value->IsUndefined()) {
2228  ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
2229  Execution::ToNumber(isolate, value), Object);
2230  }
2231  }
2232 
2233  MaybeHandle<Object> result = JSObject::SetElement(
2234  js_object, index, value, NONE, strict_mode, true, SET_PROPERTY);
2235  JSObject::ValidateElements(js_object);
2236 
2237  return result.is_null() ? result : value;
2238  }
2239 
2240  if (key->IsName()) {
2241  Handle<Name> name = Handle<Name>::cast(key);
2242  if (name->AsArrayIndex(&index)) {
2243  // TODO(verwaest): Support non-JSObject receivers.
2244  if (!object->IsJSObject()) return value;
2245  Handle<JSObject> js_object = Handle<JSObject>::cast(object);
2246  if (js_object->HasExternalArrayElements()) {
2247  if (!value->IsNumber() && !value->IsUndefined()) {
2249  isolate, value, Execution::ToNumber(isolate, value), Object);
2250  }
2251  }
2252  return JSObject::SetElement(js_object, index, value, NONE, strict_mode,
2253  true, SET_PROPERTY);
2254  } else {
2255  if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
2256  return Object::SetProperty(object, name, value, strict_mode);
2257  }
2258  }
2259 
2260  // Call-back into JavaScript to convert the key to a string.
2261  Handle<Object> converted;
2262  ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
2263  Execution::ToString(isolate, key), Object);
2264  Handle<String> name = Handle<String>::cast(converted);
2265 
2266  if (name->AsArrayIndex(&index)) {
2267  // TODO(verwaest): Support non-JSObject receivers.
2268  if (!object->IsJSObject()) return value;
2269  Handle<JSObject> js_object = Handle<JSObject>::cast(object);
2270  return JSObject::SetElement(js_object, index, value, NONE, strict_mode,
2271  true, SET_PROPERTY);
2272  }
2273  return Object::SetProperty(object, name, value, strict_mode);
2274 }
static MUST_USE_RESULT MaybeHandle< Object > SetProperty(Handle< Object > object, Handle< Name > key, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
Definition: objects.cc:2798
int ToNumber(Register reg)

References ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Handle< T >::cast(), v8::internal::String::Flatten(), v8::internal::HandleVector(), v8::internal::MaybeHandle< T >::is_null(), name, NONE, v8::internal::SET_PROPERTY, v8::internal::JSObject::SetElement(), v8::internal::Object::SetProperty(), THROW_NEW_ERROR, v8::internal::ToNumber(), and v8::internal::JSObject::ValidateElements().

Referenced by v8::internal::MaterializeLocalContext(), v8::internal::MaterializeStackLocalsWithFrameInspector(), v8::internal::RUNTIME_FUNCTION(), v8::Object::Set(), v8::internal::SetLocalVariableValue(), and v8::internal::KeyedStoreIC::Store().

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

◆ SetupArrayBuffer()

void v8::internal::Runtime::SetupArrayBuffer ( Isolate isolate,
Handle< JSArrayBuffer array_buffer,
bool  is_external,
void *  data,
size_t  allocated_length 
)
static

Definition at line 35 of file runtime-typedarray.cc.

38  {
39  DCHECK(array_buffer->GetInternalFieldCount() ==
41  for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
42  array_buffer->SetInternalField(i, Smi::FromInt(0));
43  }
44  array_buffer->set_backing_store(data);
45  array_buffer->set_flag(Smi::FromInt(0));
46  array_buffer->set_is_external(is_external);
47 
48  Handle<Object> byte_length =
49  isolate->factory()->NewNumberFromSize(allocated_length);
50  CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
51  array_buffer->set_byte_length(*byte_length);
52 
53  array_buffer->set_weak_next(isolate->heap()->array_buffers_list());
54  isolate->heap()->set_array_buffers_list(*array_buffer);
55  array_buffer->set_weak_first_view(isolate->heap()->undefined_value());
56 }
static const int kInternalFieldCount
Definition: v8.h:2955

References v8::internal::Heap::array_buffers_list(), CHECK, DCHECK, v8::internal::Isolate::factory(), v8::internal::Smi::FromInt(), v8::internal::Isolate::heap(), v8::ArrayBuffer::kInternalFieldCount, and v8::internal::Heap::set_array_buffers_list().

Referenced by v8::ArrayBuffer::New(), and SetupArrayBufferAllocatingData().

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

◆ SetupArrayBufferAllocatingData()

bool v8::internal::Runtime::SetupArrayBufferAllocatingData ( Isolate isolate,
Handle< JSArrayBuffer array_buffer,
size_t  allocated_length,
bool  initialize = true 
)
static

Definition at line 59 of file runtime-typedarray.cc.

62  {
63  void* data;
65  if (allocated_length != 0) {
66  if (initialize) {
67  data = V8::ArrayBufferAllocator()->Allocate(allocated_length);
68  } else {
69  data =
71  }
72  if (data == NULL) return false;
73  } else {
74  data = NULL;
75  }
76 
77  SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length);
78 
79  reinterpret_cast<v8::Isolate*>(isolate)
80  ->AdjustAmountOfExternalAllocatedMemory(allocated_length);
81 
82  return true;
83 }
virtual void * Allocate(size_t length)=0
Allocate |length| bytes.
virtual void * AllocateUninitialized(size_t length)=0
Allocate |length| bytes.
static void SetupArrayBuffer(Isolate *isolate, Handle< JSArrayBuffer > array_buffer, bool is_external, void *data, size_t allocated_length)

References v8::ArrayBuffer::Allocator::Allocate(), v8::ArrayBuffer::Allocator::AllocateUninitialized(), v8::internal::V8::ArrayBufferAllocator(), CHECK, NULL, and SetupArrayBuffer().

Referenced by v8::internal::JSTypedArray::MaterializeArrayBuffer(), v8::ArrayBuffer::New(), and v8::internal::RUNTIME_FUNCTION().

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

◆ StringMatch()

int v8::internal::Runtime::StringMatch ( Isolate isolate,
Handle< String sub,
Handle< String pat,
int  index 
)
static

Definition at line 1094 of file runtime-regexp.cc.

1095  {
1096  DCHECK(0 <= start_index);
1097  DCHECK(start_index <= sub->length());
1098 
1099  int pattern_length = pat->length();
1100  if (pattern_length == 0) return start_index;
1101 
1102  int subject_length = sub->length();
1103  if (start_index + pattern_length > subject_length) return -1;
1104 
1105  sub = String::Flatten(sub);
1106  pat = String::Flatten(pat);
1107 
1108  DisallowHeapAllocation no_gc; // ensure vectors stay valid
1109  // Extract flattened substrings of cons strings before getting encoding.
1110  String::FlatContent seq_sub = sub->GetFlatContent();
1111  String::FlatContent seq_pat = pat->GetFlatContent();
1112 
1113  // dispatch on type of strings
1114  if (seq_pat.IsOneByte()) {
1115  Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector();
1116  if (seq_sub.IsOneByte()) {
1117  return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector,
1118  start_index);
1119  }
1120  return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector,
1121  start_index);
1122  }
1123  Vector<const uc16> pat_vector = seq_pat.ToUC16Vector();
1124  if (seq_sub.IsOneByte()) {
1125  return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector,
1126  start_index);
1127  }
1128  return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, start_index);
1129 }
int SearchString(Isolate *isolate, Vector< const SubjectChar > subject, Vector< const PatternChar > pattern, int start_index)

References DCHECK, v8::internal::String::Flatten(), v8::internal::String::FlatContent::IsOneByte(), v8::internal::SearchString(), v8::internal::String::FlatContent::ToOneByteVector(), and v8::internal::String::FlatContent::ToUC16Vector().

Referenced by v8::internal::RUNTIME_FUNCTION(), and v8::internal::StringReplaceOneCharWithString().

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

Member Data Documentation

◆ kNotFound

const int v8::internal::Runtime::kNotFound = -1
static

Definition at line 807 of file runtime.h.

Referenced by FunctionForName().


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