46 static C* FindInstanceOf(Isolate* isolate,
Object*
obj) {
47 for (
Object* cur = obj; !cur->IsNull(); cur = cur->GetPrototype(isolate)) {
48 if (Is<C>(cur))
return C::cast(cur);
55 MaybeObject* Accessors::IllegalSetter(Isolate* isolate,
64 Object* Accessors::IllegalGetAccessor(Isolate* isolate,
72 MaybeObject* Accessors::ReadOnlySetAccessor(Isolate* isolate,
83 String* property_name,
86 if (name->Equals(property_name)) {
87 *object_offset = offset;
100 Isolate* isolate = name->GetIsolate();
102 if (type->Is(T::String())) {
103 return CheckForName(name, isolate->
heap()->length_string(),
107 if (!type->IsClass())
return false;
110 switch (map->instance_type()) {
113 CheckForName(name, isolate->
heap()->length_string(),
117 CheckForName(name, isolate->
heap()->length_string(),
119 CheckForName(name, isolate->
heap()->byte_length_string(),
121 CheckForName(name, isolate->
heap()->byte_offset_string(),
125 CheckForName(name, isolate->
heap()->byte_length_string(),
129 CheckForName(name, isolate->
heap()->byte_length_string(),
131 CheckForName(name, isolate->
heap()->byte_offset_string(),
140 bool Accessors::IsJSObjectFieldAccessor<Type>(
Type* type,
156 MaybeObject* Accessors::ArrayGetLength(
Isolate* isolate,
160 JSArray* holder = FindInstanceOf<JSArray>(isolate, object);
168 if (value->
IsNumber() || !value->IsJSValue())
return value;
170 ASSERT(wrapper->GetIsolate()->context()->native_context()->number_function()->
172 if (wrapper->map() ==
173 isolate->context()->native_context()->number_function()->initial_map()) {
174 return handle(wrapper->value(), isolate);
181 MaybeObject* Accessors::ArraySetLength(Isolate* isolate,
182 JSObject* object_raw,
185 HandleScope scope(isolate);
186 Handle<JSObject> object(object_raw, isolate);
187 Handle<Object> value(value_raw, isolate);
192 if (!object->IsJSArray()) {
194 isolate->factory()->length_string(), value,
NONE);
199 value = FlattenNumber(isolate, value);
204 Handle<Object> uint32_v =
207 Handle<Object> number_v =
211 if (uint32_v->Number() == number_v->Number()) {
216 return isolate->Throw(
217 *isolate->factory()->NewRangeError(
"invalid_array_length",
218 HandleVector<Object>(
NULL, 0)));
222 const AccessorDescriptor Accessors::ArrayLength = {
234 MaybeObject* Accessors::StringGetLength(Isolate* isolate,
238 if (object->IsJSValue()) value =
JSValue::cast(
object)->value();
246 const AccessorDescriptor Accessors::StringLength = {
258 MaybeObject* Accessors::ScriptGetSource(Isolate* isolate,
266 const AccessorDescriptor Accessors::ScriptSource = {
278 MaybeObject* Accessors::ScriptGetName(Isolate* isolate,
286 const AccessorDescriptor Accessors::ScriptName = {
298 MaybeObject* Accessors::ScriptGetId(Isolate* isolate,
Object*
object,
void*) {
304 const AccessorDescriptor Accessors::ScriptId = {
316 MaybeObject* Accessors::ScriptGetLineOffset(Isolate* isolate,
324 const AccessorDescriptor Accessors::ScriptLineOffset = {
336 MaybeObject* Accessors::ScriptGetColumnOffset(Isolate* isolate,
344 const AccessorDescriptor Accessors::ScriptColumnOffset = {
345 ScriptGetColumnOffset,
356 MaybeObject* Accessors::ScriptGetType(Isolate* isolate,
364 const AccessorDescriptor Accessors::ScriptType = {
376 MaybeObject* Accessors::ScriptGetCompilationType(Isolate* isolate,
384 const AccessorDescriptor Accessors::ScriptCompilationType = {
385 ScriptGetCompilationType,
396 MaybeObject* Accessors::ScriptGetLineEnds(Isolate* isolate,
400 HandleScope scope(isolate);
401 Handle<Script> script(
Script::cast(wrapper->value()), isolate);
403 ASSERT(script->line_ends()->IsFixedArray());
406 ASSERT(*line_ends == isolate->heap()->empty_fixed_array() ||
407 line_ends->map() == isolate->heap()->fixed_cow_array_map());
408 Handle<JSArray> js_array =
409 isolate->factory()->NewJSArrayWithElements(line_ends);
414 const AccessorDescriptor Accessors::ScriptLineEnds = {
426 MaybeObject* Accessors::ScriptGetContextData(Isolate* isolate,
434 const AccessorDescriptor Accessors::ScriptContextData = {
435 ScriptGetContextData,
446 MaybeObject* Accessors::ScriptGetEvalFromScript(Isolate* isolate,
450 if (!
Script::cast(script)->eval_from_shared()->IsUndefined()) {
451 Handle<SharedFunctionInfo> eval_from_shared(
454 if (eval_from_shared->script()->IsScript()) {
455 Handle<Script> eval_from_script(
Script::cast(eval_from_shared->script()));
459 return isolate->heap()->undefined_value();
463 const AccessorDescriptor Accessors::ScriptEvalFromScript = {
464 ScriptGetEvalFromScript,
475 MaybeObject* Accessors::ScriptGetEvalFromScriptPosition(Isolate* isolate,
479 HandleScope scope(isolate);
480 Handle<Script> script(raw_script);
484 return script->GetHeap()->undefined_value();
490 script->eval_from_shared())->
code());
492 script->eval_from_instructions_offset()->value()));
496 const AccessorDescriptor Accessors::ScriptEvalFromScriptPosition = {
497 ScriptGetEvalFromScriptPosition,
508 MaybeObject* Accessors::ScriptGetEvalFromFunctionName(Isolate* isolate,
517 if (!shared->name()->IsUndefined()) {
518 return shared->name();
520 return shared->inferred_name();
525 const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
526 ScriptGetEvalFromFunctionName,
548 ASSERT(function->should_have_prototype());
561 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object);
562 if (function_raw ==
NULL)
return isolate->heap()->undefined_value();
564 function_raw = FindInstanceOf<JSFunction>(isolate,
573 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(
function);
575 function_raw = *
function;
582 JSObject* object_raw,
585 JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object_raw);
586 if (function_raw ==
NULL)
return isolate->heap()->undefined_value();
588 HandleScope scope(isolate);
589 Handle<JSFunction>
function(function_raw, isolate);
590 Handle<JSObject> object(object_raw, isolate);
591 Handle<Object> value(value_raw, isolate);
592 if (!function->should_have_prototype()) {
595 isolate->factory()->prototype_string(), value,
NONE);
600 Handle<Object> old_value;
601 bool is_observed = *
function == *
object &&
function->map()->is_observed();
603 if (function->has_prototype())
604 old_value =
handle(function->prototype(), isolate);
606 old_value = isolate->factory()->NewFunctionPrototype(
function);
610 ASSERT(function->prototype() == *value);
612 if (is_observed && !old_value->SameValue(*value)) {
614 function,
"update", isolate->factory()->prototype_string(), old_value);
621 const AccessorDescriptor Accessors::FunctionPrototype = {
622 FunctionGetPrototype,
623 FunctionSetPrototype,
633 MaybeObject* Accessors::FunctionGetLength(Isolate* isolate,
636 JSFunction*
function = FindInstanceOf<JSFunction>(isolate, object);
639 if (function->shared()->is_compiled()) {
644 HandleScope scope(isolate);
645 Handle<JSFunction> function_handle(
function);
647 return Smi::FromInt(function_handle->shared()->length());
653 const AccessorDescriptor Accessors::FunctionLength = {
665 MaybeObject* Accessors::FunctionGetName(Isolate* isolate,
668 JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
669 return holder ==
NULL
670 ? isolate->heap()->undefined_value()
671 : holder->shared()->name();
675 const AccessorDescriptor Accessors::FunctionName = {
696 static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
699 int inlined_frame_index) {
700 Isolate* isolate = inlined_function->GetIsolate();
702 SlotRefValueBuilder slot_refs(
705 inlined_function->shared()->formal_parameter_count());
707 int args_count = slot_refs.args_length();
711 slot_refs.Prepare(isolate);
712 for (
int i = 0; i < args_count; ++i) {
714 array->set(i, *value);
716 slot_refs.Finish(isolate);
717 arguments->set_elements(*array);
727 HandleScope scope(isolate);
728 JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
729 if (holder ==
NULL)
return isolate->heap()->undefined_value();
730 Handle<JSFunction>
function(holder, isolate);
732 if (function->shared()->native())
return isolate->heap()->null_value();
734 List<JSFunction*> functions(2);
735 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
736 JavaScriptFrame* frame = it.frame();
738 for (
int i = functions.length() - 1; i >= 0; i--) {
740 if (functions[i] != *
function)
continue;
747 return ConstructArgumentsObjectForInlinedFunction(frame,
function, i);
750 if (!frame->is_optimized()) {
752 Handle<ScopeInfo> scope_info(function->shared()->scope_info());
753 int index = scope_info->StackSlotIndex(
754 isolate->heap()->arguments_string());
756 Handle<Object> arguments(frame->GetExpression(index), isolate);
757 if (!arguments->IsArgumentsMarker())
return *arguments;
764 it.AdvanceToArgumentsFrame();
769 const int length = frame->ComputeParametersCount();
770 Handle<JSObject> arguments = isolate->factory()->NewArgumentsObject(
772 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
775 ASSERT(array->length() == length);
776 for (
int i = 0; i < length; i++) array->set(i, frame->GetParameter(i));
777 arguments->set_elements(*array);
786 return isolate->heap()->null_value();
790 const AccessorDescriptor Accessors::FunctionArguments = {
791 FunctionGetArguments,
805 : frame_iterator_(isolate),
811 if (functions_.length() == 0)
return NULL;
812 JSFunction* next_function = functions_[index_];
817 return next_function;
826 next_function =
next();
827 if (next_function ==
function)
return true;
828 }
while (next_function !=
NULL);
833 void GetFunctions() {
834 functions_.Rewind(0);
835 if (frame_iterator_.done())
return;
838 ASSERT(functions_.length() > 0);
839 frame_iterator_.Advance();
840 index_ = functions_.length() - 1;
842 JavaScriptFrameIterator frame_iterator_;
843 List<JSFunction*> functions_;
848 MaybeObject* Accessors::FunctionGetCaller(Isolate* isolate,
851 HandleScope scope(isolate);
853 JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object);
854 if (holder ==
NULL)
return isolate->heap()->undefined_value();
855 if (holder->shared()->native())
return isolate->heap()->null_value();
856 Handle<JSFunction>
function(holder, isolate);
858 FrameFunctionIterator it(isolate, no_allocation);
861 if (!it.Find(*
function)) {
863 return isolate->heap()->null_value();
870 if (caller ==
NULL)
return isolate->heap()->null_value();
871 }
while (caller->shared()->is_toplevel());
875 JSFunction* potential_caller = caller;
876 while (potential_caller !=
NULL && potential_caller->IsBuiltin()) {
877 caller = potential_caller;
878 potential_caller = it.next();
880 if (!caller->shared()->native() && potential_caller !=
NULL) {
881 caller = potential_caller;
886 if (caller->shared()->bound()) {
887 return isolate->heap()->null_value();
892 if (caller->shared()->strict_mode() ==
STRICT) {
893 return isolate->heap()->null_value();
900 const AccessorDescriptor Accessors::FunctionCaller = {
911 static void ModuleGetExport(
916 ASSERT(context->IsModuleContext());
917 int slot = info.
Data()->Int32Value();
918 Object* value = context->get(slot);
919 Isolate* isolate = instance->GetIsolate();
920 if (value->IsTheHole()) {
922 isolate->ScheduleThrow(
923 *isolate->factory()->NewReferenceError(
"not_defined",
931 static void ModuleSetExport(
937 ASSERT(context->IsModuleContext());
938 int slot = info.
Data()->Int32Value();
939 Object* old_value = context->get(slot);
940 if (old_value->IsTheHole()) {
942 Isolate* isolate = instance->GetIsolate();
943 isolate->ScheduleThrow(
944 *isolate->factory()->NewReferenceError(
"not_defined",
956 Isolate* isolate = name->GetIsolate();
959 info->set_property_attributes(attributes);
960 info->set_all_can_read(
true);
961 info->set_all_can_write(
true);
962 info->set_name(*name);
966 info->set_getter(*getter);
967 if (!(attributes &
ReadOnly)) info->set_setter(*setter);
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 NULL
bool Find(JSFunction *function)
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 map
static Handle< Object > ToNumber(Isolate *isolate, Handle< Object > obj, bool *exc)
static String * cast(Object *obj)
static void SetPrototype(Handle< JSFunction > function, Handle< Object > value)
static Smi * FromInt(int value)
static Handle< T > cast(Handle< S > that)
static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, Handle< String > name, int *object_offset)
kSerializedDataOffset Object
static Failure * Exception()
V8_INLINE Local< Object > Holder() const
static bool EnsureCompiled(Handle< JSFunction > function, ClearExceptionFlag flag)
static const int kByteLengthOffset
void InitScriptLineEnds(Handle< Script > script)
#define ASSERT(condition)
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< Name > key, Handle< Object > value, PropertyAttributes attributes, ValueType value_type=OPTIMAL_REPRESENTATION, StoreMode mode=ALLOW_AS_CONSTANT, ExtensibilityCheck extensibility_check=PERFORM_EXTENSIBILITY_CHECK)
static Script * cast(Object *obj)
static Context * cast(Object *context)
static SharedFunctionInfo * cast(Object *obj)
static Handle< Object > FunctionSetPrototype(Handle< JSFunction > object, Handle< Object > value)
Handle< JSObject > NewArgumentsObject(Handle< Object > callee, int length)
#define RETURN_IF_EMPTY_HANDLE(isolate, call)
static const int kLengthOffset
#define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE)
static const int kByteLengthOffset
Handle< ExecutableAccessorInfo > NewExecutableAccessorInfo()
FrameFunctionIterator(Isolate *isolate, const DisallowHeapAllocation &promise)
Handle< JSValue > GetScriptWrapper(Handle< Script > script)
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
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
V8_INLINE ReturnValue< T > GetReturnValue() const
static const int kByteOffsetOffset
static const int kLengthOffset
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static const int kLengthOffset
static Handle< AccessorInfo > MakeModuleExport(Handle< String > name, int index, PropertyAttributes attributes)
static Handle< Object > FunctionGetArguments(Handle< JSFunction > object)
v8::internal::Handle< v8::internal::Object > FromCData(v8::internal::Isolate *isolate, T obj)
static void EnqueueChangeRecord(Handle< JSObject > object, const char *type, Handle< Name > name, Handle< Object > old_value)
static Handle< Object > SetElementsLength(Handle< JSArray > array, Handle< Object > length)
bool should_have_prototype()
Handle< T > handle(T *t, Isolate *isolate)
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 info
virtual void GetFunctions(List< JSFunction * > *functions)
static JSValue * cast(Object *obj)
static Handle< Object > ToUint32(Isolate *isolate, Handle< Object > obj, bool *exc)
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
static FixedArray * cast(Object *obj)
Vector< Handle< Object > > HandleVector(v8::internal::Handle< T > *elms, int length)
static Handle< Object > FunctionGetPrototype(Handle< JSFunction > object)
static JSModule * cast(Object *obj)
V8_INLINE Local< Value > Data() const
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 emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name