V8 Project
api.cc File Reference
#include "src/api.h"
#include <string.h>
#include <cmath>
#include "include/v8-debug.h"
#include "include/v8-profiler.h"
#include "include/v8-testing.h"
#include "src/assert-scope.h"
#include "src/background-parsing-task.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/utils/random-number-generator.h"
#include "src/bootstrapper.h"
#include "src/code-stubs.h"
#include "src/compiler.h"
#include "src/conversions-inl.h"
#include "src/counters.h"
#include "src/cpu-profiler.h"
#include "src/debug.h"
#include "src/deoptimizer.h"
#include "src/execution.h"
#include "src/global-handles.h"
#include "src/heap-profiler.h"
#include "src/heap-snapshot-generator-inl.h"
#include "src/icu_util.h"
#include "src/json-parser.h"
#include "src/messages.h"
#include "src/natives.h"
#include "src/parser.h"
#include "src/profile-generator-inl.h"
#include "src/property.h"
#include "src/property-details.h"
#include "src/prototype.h"
#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
#include "src/scanner-character-streams.h"
#include "src/simulator.h"
#include "src/snapshot.h"
#include "src/unicode-inl.h"
#include "src/v8threads.h"
#include "src/version.h"
#include "src/vm-state-inl.h"
+ Include dependency graph for api.cc:

Go to the source code of this file.

Classes

struct  v8::OneByteMask< 4 >
 
struct  v8::OneByteMask< 8 >
 
class  v8::ContainsOnlyOneByteHelper
 
class  v8::Utf8LengthHelper
 
class  v8::Utf8LengthHelper::Visitor
 
class  v8::Utf8WriterVisitor
 
class  v8::VisitorAdapter
 

Namespaces

 v8
 Debugger support for the V8 JavaScript engine.
 
 v8::anonymous_namespace{api.cc}
 
 v8::internal
 

Macros

#define LOG_API(isolate, expr)   LOG(isolate, ApiEntryCall(expr))
 
#define ENTER_V8(isolate)
 
#define ON_BAILOUT(isolate, location, code)
 
#define EXCEPTION_PREAMBLE(isolate)
 
#define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback)
 
#define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value)
 
#define EXCEPTION_BAILOUT_CHECK(isolate, value)    EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;)
 
#define SET_FIELD_WRAPPED(obj, setter, cdata)
 
#define VALUE_IS_TYPED_ARRAY(Type, typeName, TYPE, ctype, size)
 
#define VALUE_IS_SPECIFIC_TYPE(Type, Class)
 
#define CHECK_TYPED_ARRAY_CAST(Type, typeName, TYPE, ctype, size)
 
#define ARRAY_TYPE_TO_ELEMENTS_KIND(Type, type, TYPE, ctype, size)
 
#define INSTANCE_TYPE_TO_ARRAY_TYPE(Type, type, TYPE, ctype, size)
 
#define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag)
 
#define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size)
 
#define DEFINE_ERROR(NAME)
 

Enumerations

enum  v8::CompressedStartupDataItems {
  v8::kSnapshot = 0 , v8::kSnapshotContext , v8::kLibraries , v8::kExperimentalLibraries ,
  v8::kCompressedStartupDataCount
}
 

Functions

static bool v8::IsExecutionTerminatingCheck (i::Isolate *isolate)
 
void v8::RegisterExtension (Extension *that)
 
void v8::SetResourceConstraints (i::Isolate *isolate, const ResourceConstraints &constraints)
 
static void * v8::DecodeSmiToAligned (i::Object *value, const char *location)
 
static i::Smiv8::EncodeAlignedAsSmi (void *value, const char *location)
 
static i::Handle< i::FixedArrayv8::EmbedderDataFor (Context *context, int index, bool can_grow, const char *location)
 
static void v8::InitializeTemplate (i::Handle< i::TemplateInfo > that, int type)
 
static void v8::TemplateSet (i::Isolate *isolate, v8::Template *templ, int length, v8::Handle< v8::Data > *data)
 
static void v8::InitializeFunctionTemplate (i::Handle< i::FunctionTemplateInfo > info)
 
static Local< FunctionTemplate > v8::FunctionTemplateNew (i::Isolate *isolate, FunctionCallback callback, v8::Handle< Value > data, v8::Handle< Signature > signature, int length, bool do_not_cache)
 
template<typename Operation >
static Local< Operation > v8::NewDescriptor (Isolate *isolate, const i::DeclaredAccessorDescriptorData &data, Data *previous_descriptor)
 
template<typename T >
static Local< DeclaredAccessorDescriptor > v8::NewBitmaskCompare (Isolate *isolate, T bitmask, T compare_value, RawOperationDescriptor *operation)
 
static i::Handle< i::AccessorInfov8::SetAccessorInfoProperties (i::Handle< i::AccessorInfo > obj, v8::Handle< Name > name, v8::AccessControl settings, v8::PropertyAttribute attributes, v8::Handle< AccessorSignature > signature)
 
template<typename Getter , typename Setter >
static i::Handle< i::AccessorInfov8::MakeAccessorInfo (v8::Handle< Name > name, Getter getter, Setter setter, v8::Handle< Value > data, v8::AccessControl settings, v8::PropertyAttribute attributes, v8::Handle< AccessorSignature > signature)
 
static i::Handle< i::AccessorInfov8::MakeAccessorInfo (v8::Handle< Name > name, v8::Handle< v8::DeclaredAccessorDescriptor > descriptor, void *setter_ignored, void *data_ignored, v8::AccessControl settings, v8::PropertyAttribute attributes, v8::Handle< AccessorSignature > signature)
 
static i::Handle< i::FunctionTemplateInfov8::EnsureConstructor (i::Isolate *isolate, ObjectTemplate *object_template)
 
static void v8::AddPropertyToTemplate (i::Handle< i::TemplateInfo > info, i::Handle< i::AccessorInfo > obj)
 
static i::Handle< i::TemplateInfov8::GetTemplateInfo (i::Isolate *isolate, Template *template_obj)
 
static i::Handle< i::TemplateInfov8::GetTemplateInfo (i::Isolate *isolate, ObjectTemplate *object_template)
 
template<typename Getter , typename Setter , typename Data , typename Template >
static bool v8::TemplateSetAccessor (Template *template_obj, v8::Local< Name > name, Getter getter, Setter setter, Data data, AccessControl settings, PropertyAttribute attribute, v8::Local< AccessorSignature > signature)
 
static MUST_USE_RESULT i::MaybeHandle< i::Objectv8::CallV8HeapFunction (const char *name, i::Handle< i::Object > recv, int argc, i::Handle< i::Object > argv[])
 
static MUST_USE_RESULT i::MaybeHandle< i::Objectv8::CallV8HeapFunction (const char *name, i::Handle< i::Object > data)
 
static int v8::getIntProperty (const StackFrame *f, const char *propertyName, int defaultValue)
 
static Local< String > v8::getStringProperty (const StackFrame *f, const char *propertyName)
 
static bool v8::getBoolProperty (const StackFrame *f, const char *propertyName)
 
static bool v8::CheckConstructor (i::Isolate *isolate, i::Handle< i::JSObject > obj, const char *class_name)
 
template<typename Getter , typename Setter , typename Data >
static bool v8::ObjectSetAccessor (Object *obj, Handle< Name > name, Getter getter, Setter setter, Data data, AccessControl settings, PropertyAttribute attributes)
 
static Local< Value > v8::GetPropertyByLookup (i::LookupIterator *it)
 
static i::ElementsKind v8::anonymous_namespace{api.cc}::GetElementsKindFromExternalArrayType (ExternalArrayType array_type)
 
void v8::anonymous_namespace{api.cc}::PrepareExternalArrayElements (i::Handle< i::JSObject > object, void *data, ExternalArrayType array_type, int length)
 
static bool v8::Unaligned (const uint16_t *chars)
 
static const uint16_t * v8::Align (const uint16_t *chars)
 
static int v8::Utf8Length (i::String *str, i::Isolate *isolate)
 
static bool v8::RecursivelySerializeToUtf8 (i::String *current, Utf8WriterVisitor *writer, int recursion_budget)
 
template<typename CharType >
static int v8::WriteHelper (const String *string, CharType *buffer, int start, int length, int options)
 
static bool v8::InternalFieldOK (i::Handle< i::JSObject > obj, int index, const char *location)
 
static void * v8::ExternalValue (i::Object *obj)
 
static i::Handle< i::Contextv8::CreateEnvironment (i::Isolate *isolate, v8::ExtensionConfiguration *extensions, v8::Handle< ObjectTemplate > global_template, v8::Handle< Value > maybe_global_proxy)
 
int v8::anonymous_namespace{api.cc}::StringLength (const char *string)
 
int v8::anonymous_namespace{api.cc}::StringLength (const uint8_t *string)
 
int v8::anonymous_namespace{api.cc}::StringLength (const uint16_t *string)
 
MUST_USE_RESULT i::MaybeHandle< i::Stringv8::anonymous_namespace{api.cc}::NewString (i::Factory *factory, String::NewStringType type, i::Vector< const char > string)
 
MUST_USE_RESULT i::MaybeHandle< i::Stringv8::anonymous_namespace{api.cc}::NewString (i::Factory *factory, String::NewStringType type, i::Vector< const uint8_t > string)
 
MUST_USE_RESULT i::MaybeHandle< i::Stringv8::anonymous_namespace{api.cc}::NewString (i::Factory *factory, String::NewStringType type, i::Vector< const uint16_t > string)
 
template<typename Char >
Local< String > v8::anonymous_namespace{api.cc}::NewString (Isolate *v8_isolate, const char *location, const char *env, const Char *data, String::NewStringType type, int length)
 
static i::MaybeHandle< i::Stringv8::NewExternalStringHandle (i::Isolate *isolate, v8::String::ExternalStringResource *resource)
 
static i::MaybeHandle< i::Stringv8::NewExternalOneByteStringHandle (i::Isolate *isolate, v8::String::ExternalOneByteStringResource *resource)
 
static i::Handle< i::Stringv8::RegExpFlagsToString (RegExp::Flags flags)
 
 v8::REGEXP_FLAG_ASSERT_EQ (kNone, NONE)
 
 v8::REGEXP_FLAG_ASSERT_EQ (kGlobal, GLOBAL)
 
 v8::REGEXP_FLAG_ASSERT_EQ (kIgnoreCase, IGNORE_CASE)
 
 v8::REGEXP_FLAG_ASSERT_EQ (kMultiline, MULTILINE)
 
static void v8::SetupArrayBufferView (i::Isolate *isolate, i::Handle< i::JSArrayBufferView > obj, i::Handle< i::JSArrayBuffer > buffer, size_t byte_offset, size_t byte_length)
 
template<typename ElementType , ExternalArrayType array_type, i::ElementsKind elements_kind>
i::Handle< i::JSTypedArrayv8::NewTypedArray (i::Isolate *isolate, Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
 
static i::Handle< i::Symbolv8::SymbolFor (i::Isolate *isolate, i::Handle< i::String > name, i::Handle< i::String > part)
 
static Local< Symbol > v8::GetWellKnownSymbol (Isolate *isolate, const char *name)
 
static i::HeapGraphEdge * v8::ToInternal (const HeapGraphEdge *edge)
 
static i::HeapEntry * v8::ToInternal (const HeapGraphNode *entry)
 
static i::HeapSnapshotv8::ToInternal (const HeapSnapshot *snapshot)
 
static void v8::SetFlagsFromString (const char *flags)
 
void v8::internal::InvokeAccessorGetterCallback (v8::Local< v8::Name > property, const v8::PropertyCallbackInfo< v8::Value > &info, v8::AccessorNameGetterCallback getter)
 
void v8::internal::InvokeFunctionCallback (const v8::FunctionCallbackInfo< v8::Value > &info, v8::FunctionCallback callback)
 

Variables

static const uintptr_t v8::kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value
 
static const uintptr_t v8::kAlignmentMask = sizeof(uintptr_t) - 1
 

Macro Definition Documentation

◆ ARRAY_TYPE_TO_ELEMENTS_KIND

#define ARRAY_TYPE_TO_ELEMENTS_KIND (   Type,
  type,
  TYPE,
  ctype,
  size 
)
Value:
case kExternal##Type##Array: \
return i::EXTERNAL_##TYPE##_ELEMENTS;
TypeImpl< ZoneTypeConfig > Type

◆ CHECK_TYPED_ARRAY_CAST

#define CHECK_TYPED_ARRAY_CAST (   Type,
  typeName,
  TYPE,
  ctype,
  size 
)
Value:
void v8::Type##Array::CheckCast(Value* that) { \
i::Handle<i::Object> obj = Utils::OpenHandle(that); \
Utils::ApiCheck(obj->IsJSTypedArray() && \
i::JSTypedArray::cast(*obj)->type() == \
kExternal##Type##Array, \
"v8::" #Type "Array::Cast()", \
"Could not convert to " #Type "Array"); \
}

Definition at line 2808 of file api.cc.

◆ DEFINE_ERROR

#define DEFINE_ERROR (   NAME)
Value:
Local<Value> Exception::NAME(v8::Handle<v8::String> raw_message) { \
i::Isolate* isolate = i::Isolate::Current(); \
LOG_API(isolate, #NAME); \
ON_BAILOUT(isolate, "v8::Exception::" #NAME "()", return Local<Value>()); \
ENTER_V8(isolate); \
i::Object* error; \
{ \
i::HandleScope scope(isolate); \
i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \
i::Handle<i::Object> result; \
EXCEPTION_PREAMBLE(isolate); \
i::MaybeHandle<i::Object> maybe_result = \
isolate->factory()->New##NAME(message); \
has_pending_exception = !maybe_result.ToHandle(&result); \
/* TODO(yangguo): crbug/403509. Return empty handle instead. */ \
EXCEPTION_BAILOUT_CHECK( \
isolate, v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate))); \
error = *result; \
} \
i::Handle<i::Object> result(error, isolate); \
return Utils::ToLocal(result); \
}
An object reference managed by the v8 garbage collector.
Definition: v8.h:198
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
kSerializedDataOffset Object
Definition: objects-inl.h:5322
Handle< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:6836

Definition at line 6882 of file api.cc.

◆ ENTER_V8

#define ENTER_V8 (   isolate)
Value:
DCHECK((isolate)->IsInitialized()); \
i::VMState<i::OTHER> __state__((isolate))
#define DCHECK(condition)
Definition: logging.h:205

Definition at line 54 of file api.cc.

◆ EXCEPTION_BAILOUT_CHECK

#define EXCEPTION_BAILOUT_CHECK (   isolate,
  value 
)     EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;)

Definition at line 93 of file api.cc.

◆ EXCEPTION_BAILOUT_CHECK_DO_CALLBACK

#define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK (   isolate,
  value 
)
Value:
isolate, value, isolate->FireCallCompletedCallback();)
#define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback)
Definition: api.cc:73

Definition at line 88 of file api.cc.

◆ EXCEPTION_BAILOUT_CHECK_GENERIC

#define EXCEPTION_BAILOUT_CHECK_GENERIC (   isolate,
  value,
  do_callback 
)
Value:
do { \
i::HandleScopeImplementer* handle_scope_implementer = \
(isolate)->handle_scope_implementer(); \
handle_scope_implementer->DecrementCallDepth(); \
if (has_pending_exception) { \
bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
(isolate)->OptionalRescheduleException(call_depth_is_zero); \
do_callback \
return value; \
} \
do_callback \
} while (false)

Definition at line 73 of file api.cc.

◆ EXCEPTION_PREAMBLE

#define EXCEPTION_PREAMBLE (   isolate)
Value:
(isolate)->handle_scope_implementer()->IncrementCallDepth(); \
DCHECK(!(isolate)->external_caught_exception()); \
bool has_pending_exception = false

Definition at line 67 of file api.cc.

◆ INSTANCE_TYPE_TO_ARRAY_TYPE

#define INSTANCE_TYPE_TO_ARRAY_TYPE (   Type,
  type,
  TYPE,
  ctype,
  size 
)
Value:
case i::EXTERNAL_##TYPE##_ARRAY_TYPE: \
return kExternal##Type##Array;

◆ LOG_API

#define LOG_API (   isolate,
  expr 
)    LOG(isolate, ApiEntryCall(expr))

Definition at line 52 of file api.cc.

◆ ON_BAILOUT

#define ON_BAILOUT (   isolate,
  location,
  code 
)
Value:
if (IsExecutionTerminatingCheck(isolate)) { \
code; \
UNREACHABLE(); \
}
static bool IsExecutionTerminatingCheck(i::Isolate *isolate)
Definition: api.cc:195

Definition at line 60 of file api.cc.

◆ REGEXP_FLAG_ASSERT_EQ

#define REGEXP_FLAG_ASSERT_EQ (   api_flag,
  internal_flag 
)
Value:
STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \
static_cast<int>(i::JSRegExp::internal_flag))
#define STATIC_ASSERT(test)
Definition: macros.h:311

Definition at line 5790 of file api.cc.

◆ SET_FIELD_WRAPPED

#define SET_FIELD_WRAPPED (   obj,
  setter,
  cdata 
)
Value:
do { \
i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \
(obj)->setter(*foreign); \
} while (false)
v8::internal::Handle< v8::internal::Object > FromCData(v8::internal::Isolate *isolate, T obj)
Definition: api.h:104

Definition at line 1101 of file api.cc.

◆ TYPED_ARRAY_NEW

#define TYPED_ARRAY_NEW (   Type,
  type,
  TYPE,
  ctype,
  size 
)
Value:
Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
size_t byte_offset, size_t length) { \
i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \
LOG_API(isolate, \
"v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
ENTER_V8(isolate); \
if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \
"v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \
"length exceeds max allowed value")) { \
return Local<Type##Array>(); \
} \
i::Handle<i::JSTypedArray> obj = \
NewTypedArray<ctype, v8::kExternal##Type##Array, \
i::EXTERNAL_##TYPE##_ELEMENTS>( \
isolate, array_buffer, byte_offset, length); \
return Utils::ToLocal##Type##Array(obj); \
}
static const int kMaxValue
Definition: objects.h:1272

Definition at line 6136 of file api.cc.

◆ VALUE_IS_SPECIFIC_TYPE

#define VALUE_IS_SPECIFIC_TYPE (   Type,
  Class 
)
Value:
bool Value::Is##Type() const { \
i::Handle<i::Object> obj = Utils::OpenHandle(this); \
if (!obj->IsHeapObject()) return false; \
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); \
return obj->HasSpecificClassOf(isolate->heap()->Class##_string()); \
}
bool Is(Object *obj)

Definition at line 2478 of file api.cc.

◆ VALUE_IS_TYPED_ARRAY

#define VALUE_IS_TYPED_ARRAY (   Type,
  typeName,
  TYPE,
  ctype,
  size 
)
Value:
bool Value::Is##Type##Array() const { \
i::Handle<i::Object> obj = Utils::OpenHandle(this); \
return obj->IsJSTypedArray() && \
i::JSTypedArray::cast(*obj)->type() == kExternal##Type##Array; \
}

Definition at line 2451 of file api.cc.