v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
api.cc File Reference
#include "api.h"
#include <string.h>
#include <cmath>
#include "../include/v8-debug.h"
#include "../include/v8-profiler.h"
#include "../include/v8-testing.h"
#include "assert-scope.h"
#include "bootstrapper.h"
#include "code-stubs.h"
#include "compiler.h"
#include "conversions-inl.h"
#include "counters.h"
#include "cpu-profiler.h"
#include "debug.h"
#include "deoptimizer.h"
#include "execution.h"
#include "global-handles.h"
#include "heap-profiler.h"
#include "heap-snapshot-generator-inl.h"
#include "icu_util.h"
#include "json-parser.h"
#include "messages.h"
#include "parser.h"
#include "platform.h"
#include "platform/time.h"
#include "profile-generator-inl.h"
#include "property-details.h"
#include "property.h"
#include "runtime.h"
#include "runtime-profiler.h"
#include "scanner-character-streams.h"
#include "snapshot.h"
#include "unicode-inl.h"
#include "utils/random-number-generator.h"
#include "v8threads.h"
#include "version.h"
#include "vm-state-inl.h"
Include dependency graph for api.cc:

Go to the source code of this file.

Data Structures

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

Namespaces

 v8
 
 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 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)
 

Enumerations

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

Functions

void V8_EXPORT RegisterExtension (Extension *extension)
 
bool V8_EXPORT SetResourceConstraints (Isolate *isolate, ResourceConstraints *constraints)
 
 REGEXP_FLAG_ASSERT_EQ (kNone, NONE)
 
 REGEXP_FLAG_ASSERT_EQ (kGlobal, GLOBAL)
 
 REGEXP_FLAG_ASSERT_EQ (kIgnoreCase, IGNORE_CASE)
 
 REGEXP_FLAG_ASSERT_EQ (kMultiline, MULTILINE)
 
template<typename ElementType , ExternalArrayType array_type, i::ElementsKind elements_kind>
i::Handle< i::JSTypedArrayNewTypedArray (i::Isolate *isolate, Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
 
void InvokeAccessorGetterCallback (v8::Local< v8::String > property, const v8::PropertyCallbackInfo< v8::Value > &info, v8::AccessorGetterCallback getter)
 
void InvokeFunctionCallback (const v8::FunctionCallbackInfo< v8::Value > &info, v8::FunctionCallback callback)
 

Macro Definition Documentation

#define ARRAY_TYPE_TO_ELEMENTS_KIND (   Type,
  type,
  TYPE,
  ctype,
  size 
)
Value:
case kExternal##Type##Array: \
return i::EXTERNAL_##TYPE##_ELEMENTS;
TypeImpl< ZoneTypeConfig > Type
#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"); \
}
TypeImpl< ZoneTypeConfig > Type
HeapObject * obj

Definition at line 2747 of file api.cc.

#define ENTER_V8 (   isolate)
Value:
ASSERT((isolate)->IsInitialized()); \
i::VMState<i::OTHER> __state__((isolate))
#define ASSERT(condition)
Definition: checks.h:329

Definition at line 73 of file api.cc.

Referenced by V8::AddMessageListener(), Context::AllowCodeGenerationFromStrings(), StackTrace::AsArray(), Function::Call(), Object::CallAsConstructor(), Object::CallAsFunction(), Promise::Catch(), Promise::Chain(), Object::Clone(), Array::CloneElementAt(), ScriptCompiler::Compile(), ScriptCompiler::CompileUnbound(), String::Concat(), Object::CreationContext(), StackTrace::CurrentStackTrace(), Date::DateTimeConfigurationChangeNotification(), Object::Delete(), Object::DeleteHiddenValue(), Context::DetachGlobal(), V8::EnqueueMicrotask(), Context::Enter(), Value::Equals(), Exception::Error(), Context::Exit(), Object::FindInstanceInPrototypeChain(), Object::ForceDelete(), Object::ForceSet(), Message::Get(), Object::Get(), StackFrame::GetColumn(), Object::GetConstructor(), Object::GetConstructorName(), Function::GetDisplayName(), Message::GetEndColumn(), Message::GetEndPosition(), StackTrace::GetFrame(), StackTrace::GetFrameCount(), FunctionTemplate::GetFunction(), StackFrame::GetFunctionName(), Object::GetHiddenValue(), Object::GetIdentityHash(), Message::GetLineNumber(), StackFrame::GetLineNumber(), Object::GetOwnPropertyNames(), Object::GetPropertyAttributes(), Object::GetPropertyNames(), Object::GetPrototype(), Object::GetRealNamedProperty(), Object::GetRealNamedPropertyInPrototypeChain(), StackFrame::GetScriptId(), StackFrame::GetScriptName(), StackFrame::GetScriptNameOrSourceURL(), Message::GetScriptResourceName(), Message::GetSourceLine(), Message::GetStackTrace(), Message::GetStartColumn(), Message::GetStartPosition(), Object::Has(), Object::HasRealNamedCallbackProperty(), FunctionTemplate::Inherit(), FunctionTemplate::InstanceTemplate(), Value::Int32Value(), Value::IntegerValue(), Object::IsCallable(), StackFrame::IsConstructor(), StackFrame::IsEval(), Value::IsPromise(), Message::IsSharedCrossOrigin(), String::MakeExternal(), ObjectTemplate::MarkAsUndetectable(), NeanderObject::NeanderObject(), ArrayBuffer::Neuter(), Symbol::New(), Private::New(), Number::New(), Integer::New(), Object::New(), Array::New(), Function::New(), Promise::Resolver::New(), ArrayBuffer::New(), DataView::New(), Date::New(), NumberObject::New(), BooleanObject::New(), StringObject::New(), SymbolObject::New(), RegExp::New(), External::New(), FunctionTemplate::New(), Signature::New(), TypeSwitch::New(), String::NewExternal(), Integer::NewFromUnsigned(), Function::NewInstance(), ObjectTemplate::NewInstance(), Value::NumberValue(), Object::ObjectProtoToString(), JSON::Parse(), Message::PrintCurrentStackTrace(), FunctionTemplate::PrototypeTemplate(), Exception::RangeError(), FunctionTemplate::ReadOnlyPrototype(), Exception::ReferenceError(), Promise::Resolver::Reject(), V8::RemoveMessageListeners(), FunctionTemplate::RemovePrototype(), Promise::Resolver::Resolve(), Script::Run(), Object::Set(), Template::Set(), ObjectTemplate::SetAccessCheckCallbacks(), Object::SetAccessorProperty(), Template::SetAccessorProperty(), ObjectTemplate::SetCallAsFunctionHandler(), FunctionTemplate::SetCallHandler(), FunctionTemplate::SetClassName(), FunctionTemplate::SetHiddenPrototype(), Object::SetHiddenValue(), Object::SetIndexedPropertiesToExternalArrayData(), Object::SetIndexedPropertiesToPixelData(), ObjectTemplate::SetIndexedPropertyHandler(), ObjectTemplate::SetInternalFieldCount(), FunctionTemplate::SetLength(), Function::SetName(), ObjectTemplate::SetNamedPropertyHandler(), Object::SetPrototype(), Context::SetSecurityToken(), Exception::SyntaxError(), Isolate::ThrowException(), Value::ToArrayIndex(), Value::ToBoolean(), Value::ToDetailString(), Value::ToInt32(), Value::ToInteger(), Value::ToNumber(), Value::ToObject(), Value::ToString(), Value::ToUint32(), Object::TurnOnAccessCheck(), Exception::TypeError(), Value::Uint32Value(), Context::UseDefaultSecurityToken(), String::Utf8Value::Utf8Value(), String::Value::Value(), and String::WriteUtf8().

#define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK (   isolate,
  value 
)
Value:
isolate, value, i::V8::FireCallCompletedCallback(isolate);)
static void FireCallCompletedCallback(Isolate *isolate)
Definition: v8.cc:151
#define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback)
Definition: api.cc:92

Definition at line 107 of file api.cc.

Referenced by Function::Call(), Object::CallAsConstructor(), Object::CallAsFunction(), Function::NewInstance(), and Script::Run().

#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 92 of file api.cc.

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

Referenced by Object::GetIndexedPropertiesExternalArrayDataType().

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

Definition at line 71 of file api.cc.

Referenced by Function::Call(), Object::CallAsConstructor(), Object::CallAsFunction(), Promise::Catch(), Promise::Chain(), ScriptCompiler::Compile(), ScriptCompiler::CompileUnbound(), String::Concat(), Date::DateTimeConfigurationChangeNotification(), Value::Equals(), Exception::Error(), FunctionTemplate::GetFunction(), UnboundScript::GetId(), UnboundScript::GetLineNumber(), UnboundScript::GetScriptName(), Value::Int32Value(), Value::IntegerValue(), Value::IsPromise(), TypeSwitch::match(), ArrayBuffer::Neuter(), Symbol::New(), Private::New(), Object::New(), Array::New(), Function::New(), Promise::Resolver::New(), ArrayBuffer::New(), DataView::New(), Date::New(), NumberObject::New(), BooleanObject::New(), StringObject::New(), SymbolObject::New(), RegExp::New(), External::New(), FunctionTemplate::New(), Signature::New(), TypeSwitch::New(), Context::New(), String::NewExternal(), Function::NewInstance(), ObjectTemplate::NewInstance(), Value::NumberValue(), Exception::RangeError(), Exception::ReferenceError(), Promise::Resolver::Reject(), Promise::Resolver::Resolve(), Script::Run(), Value::SameValue(), Value::StrictEquals(), Exception::SyntaxError(), Value::ToArrayIndex(), Value::ToBoolean(), Value::ToDetailString(), Value::ToInt32(), Value::ToInteger(), Value::ToNumber(), Value::ToObject(), Value::ToString(), Value::ToUint32(), Exception::TypeError(), Value::Uint32Value(), Date::ValueOf(), NumberObject::ValueOf(), BooleanObject::ValueOf(), StringObject::ValueOf(), SymbolObject::ValueOf(), and String::WriteUtf8().

#define ON_BAILOUT (   isolate,
  location,
  code 
)
Value:
if (IsExecutionTerminatingCheck(isolate)) { \
}
#define UNREACHABLE()
Definition: checks.h:52
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments

Definition at line 79 of file api.cc.

Referenced by V8::AddMessageListener(), Function::Call(), Object::CallAsConstructor(), Object::CallAsFunction(), Object::Clone(), Array::CloneElementAt(), ScriptCompiler::Compile(), ScriptCompiler::CompileUnbound(), Object::CreationContext(), Date::DateTimeConfigurationChangeNotification(), Object::Delete(), Object::DeleteHiddenValue(), Exception::Error(), Object::FindInstanceInPrototypeChain(), Object::ForceDelete(), Object::ForceSet(), Message::Get(), Object::Get(), Object::GetConstructor(), Object::GetConstructorName(), Function::GetDisplayName(), FunctionTemplate::GetFunction(), Object::GetHiddenValue(), UnboundScript::GetId(), Object::GetIdentityHash(), Object::GetIndexedPropertiesExternalArrayData(), Object::GetIndexedPropertiesExternalArrayDataLength(), Object::GetIndexedPropertiesExternalArrayDataType(), Object::GetIndexedPropertiesPixelData(), Object::GetIndexedPropertiesPixelDataLength(), UnboundScript::GetLineNumber(), Message::GetLineNumber(), Object::GetOwnPropertyNames(), Object::GetPropertyAttributes(), Object::GetPropertyNames(), Object::GetPrototype(), Object::GetRealNamedProperty(), Object::GetRealNamedPropertyInPrototypeChain(), UnboundScript::GetScriptName(), Message::GetSourceLine(), Object::Has(), Object::HasIndexedLookupInterceptor(), Object::HasIndexedPropertiesInExternalArrayData(), Object::HasIndexedPropertiesInPixelData(), FunctionTemplate::HasInstance(), Object::HasNamedLookupInterceptor(), Object::HasOwnProperty(), Object::HasRealIndexedProperty(), Object::HasRealNamedCallbackProperty(), Object::HasRealNamedProperty(), Object::IsCallable(), Context::New(), Function::NewInstance(), ObjectTemplate::NewInstance(), Object::ObjectProtoToString(), Exception::RangeError(), Exception::ReferenceError(), V8::RemoveMessageListeners(), Script::Run(), Object::Set(), Object::SetAccessorProperty(), Object::SetHiddenValue(), Object::SetIndexedPropertiesToExternalArrayData(), Object::SetIndexedPropertiesToPixelData(), Object::SetPrototype(), Exception::SyntaxError(), Object::TurnOnAccessCheck(), and Exception::TypeError().

#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: checks.h:341

Definition at line 5771 of file api.cc.

#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:127
HeapObject * obj

Definition at line 1142 of file api.cc.

Referenced by ObjectTemplate::SetAccessCheckCallbacks(), ObjectTemplate::SetCallAsFunctionHandler(), FunctionTemplate::SetCallHandler(), ObjectTemplate::SetIndexedPropertyHandler(), and ObjectTemplate::SetNamedPropertyHandler().

#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 = i::Isolate::Current(); \
EnsureInitializedForIsolate(isolate, \
"v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
LOG_API(isolate, \
"v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
ENTER_V8(isolate); \
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); \
}
TypeImpl< ZoneTypeConfig > Type
#define ENTER_V8(isolate)
Definition: api.cc:73
i::Handle< i::JSTypedArray > NewTypedArray(i::Isolate *isolate, Handle< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: api.cc:6078
#define LOG_API(isolate, expr)
Definition: api.cc:71
HeapObject * obj

Definition at line 6107 of file api.cc.

#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; \
}
TypeImpl< ZoneTypeConfig > Type
bool Is(Object *obj)
HeapObject * obj

Definition at line 2394 of file api.cc.