45 static C* FindInPrototypeChain(
Object* obj,
bool* found_it) {
49 if (obj == heap->null_value())
return NULL;
50 obj = obj->GetPrototype();
58 MaybeObject* Accessors::IllegalSetter(JSObject*,
Object*,
void*) {
64 Object* Accessors::IllegalGetAccessor(
Object*
object,
void*) {
70 MaybeObject* Accessors::ReadOnlySetAccessor(JSObject*,
Object* value,
void*) {
82 MaybeObject* Accessors::ArrayGetLength(
Object*
object,
void*) {
84 bool found_it =
false;
85 JSArray* holder = FindInPrototypeChain<JSArray>(object, &found_it);
87 return holder->length();
93 if (value->IsNumber() || !value->IsJSValue())
return value;
95 ASSERT(Isolate::Current()->context()->global_context()->number_function()->
97 Map* number_map = Isolate::Current()->context()->global_context()->
98 number_function()->initial_map();
99 if (wrapper->map() == number_map)
return wrapper->value();
104 MaybeObject* Accessors::ArraySetLength(JSObject*
object,
Object* value,
void*) {
105 Isolate* isolate =
object->GetIsolate();
110 if (!object->IsJSArray()) {
111 return object->SetLocalPropertyIgnoreAttributes(
112 isolate->heap()->length_symbol(), value,
NONE);
115 value = FlattenNumber(value);
118 HandleScope scope(isolate);
121 Handle<JSObject> object_handle(
object, isolate);
122 Handle<Object> value_handle(value, isolate);
130 if (uint32_v->Number() == number_v->Number()) {
133 return isolate->Throw(
134 *isolate->factory()->NewRangeError(
"invalid_array_length",
135 HandleVector<Object>(
NULL, 0)));
139 const AccessorDescriptor Accessors::ArrayLength = {
151 MaybeObject* Accessors::StringGetLength(
Object*
object,
void*) {
153 if (object->IsJSValue()) value =
JSValue::cast(
object)->value();
161 const AccessorDescriptor Accessors::StringLength = {
173 MaybeObject* Accessors::ScriptGetSource(
Object*
object,
void*) {
179 const AccessorDescriptor Accessors::ScriptSource = {
191 MaybeObject* Accessors::ScriptGetName(
Object*
object,
void*) {
197 const AccessorDescriptor Accessors::ScriptName = {
209 MaybeObject* Accessors::ScriptGetId(
Object*
object,
void*) {
215 const AccessorDescriptor Accessors::ScriptId = {
227 MaybeObject* Accessors::ScriptGetLineOffset(
Object*
object,
void*) {
233 const AccessorDescriptor Accessors::ScriptLineOffset = {
245 MaybeObject* Accessors::ScriptGetColumnOffset(
Object*
object,
void*) {
251 const AccessorDescriptor Accessors::ScriptColumnOffset = {
252 ScriptGetColumnOffset,
263 MaybeObject* Accessors::ScriptGetData(
Object*
object,
void*) {
269 const AccessorDescriptor Accessors::ScriptData = {
281 MaybeObject* Accessors::ScriptGetType(
Object*
object,
void*) {
287 const AccessorDescriptor Accessors::ScriptType = {
299 MaybeObject* Accessors::ScriptGetCompilationType(
Object*
object,
void*) {
305 const AccessorDescriptor Accessors::ScriptCompilationType = {
306 ScriptGetCompilationType,
317 MaybeObject* Accessors::ScriptGetLineEnds(
Object*
object,
void*) {
319 Isolate* isolate = wrapper->GetIsolate();
320 HandleScope scope(isolate);
321 Handle<Script> script(
Script::cast(wrapper->value()), isolate);
323 ASSERT(script->line_ends()->IsFixedArray());
326 ASSERT(*line_ends == isolate->heap()->empty_fixed_array() ||
327 line_ends->map() == isolate->heap()->fixed_cow_array_map());
328 Handle<JSArray> js_array =
329 isolate->factory()->NewJSArrayWithElements(line_ends);
334 const AccessorDescriptor Accessors::ScriptLineEnds = {
346 MaybeObject* Accessors::ScriptGetContextData(
Object*
object,
void*) {
352 const AccessorDescriptor Accessors::ScriptContextData = {
353 ScriptGetContextData,
364 MaybeObject* Accessors::ScriptGetEvalFromScript(
Object*
object,
void*) {
366 if (!
Script::cast(script)->eval_from_shared()->IsUndefined()) {
367 Handle<SharedFunctionInfo> eval_from_shared(
370 if (eval_from_shared->script()->IsScript()) {
371 Handle<Script> eval_from_script(
Script::cast(eval_from_shared->script()));
375 return HEAP->undefined_value();
379 const AccessorDescriptor Accessors::ScriptEvalFromScript = {
380 ScriptGetEvalFromScript,
391 MaybeObject* Accessors::ScriptGetEvalFromScriptPosition(
Object*
object,
void*) {
396 int compilation_type =
Smi::cast(script->compilation_type())->value();
398 return HEAP->undefined_value();
404 script->eval_from_shared())->code());
405 return Smi::FromInt(code->SourcePosition(code->instruction_start() +
406 script->eval_from_instructions_offset()->value()));
410 const AccessorDescriptor Accessors::ScriptEvalFromScriptPosition = {
411 ScriptGetEvalFromScriptPosition,
422 MaybeObject* Accessors::ScriptGetEvalFromFunctionName(
Object*
object,
void*) {
429 if (!shared->name()->IsUndefined()) {
430 return shared->name();
432 return shared->inferred_name();
437 const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
438 ScriptGetEvalFromFunctionName,
450 Heap* heap = Isolate::Current()->heap();
451 bool found_it =
false;
452 JSFunction*
function = FindInPrototypeChain<JSFunction>(object, &found_it);
453 if (!found_it)
return heap->undefined_value();
454 while (!function->should_have_prototype()) {
456 function = FindInPrototypeChain<JSFunction>(
object->GetPrototype(),
462 if (!function->has_prototype()) {
465 if (!maybe_prototype->ToObject(&prototype))
return maybe_prototype;
468 { MaybeObject* maybe_result =
function->SetPrototype(prototype);
469 if (!maybe_result->ToObject(&result))
return maybe_result;
472 return function->prototype();
479 Heap* heap =
object->GetHeap();
480 bool found_it =
false;
481 JSFunction*
function = FindInPrototypeChain<JSFunction>(object, &found_it);
482 if (!found_it)
return heap->undefined_value();
483 if (!function->should_have_prototype()) {
485 return object->SetLocalPropertyIgnoreAttributes(heap->prototype_symbol(),
491 { MaybeObject* maybe_prototype =
function->SetPrototype(value);
492 if (!maybe_prototype->ToObject(&prototype))
return maybe_prototype;
494 ASSERT(function->prototype() == value);
500 FunctionGetPrototype,
501 FunctionSetPrototype,
511 MaybeObject* Accessors::FunctionGetLength(
Object*
object,
void*) {
512 bool found_it =
false;
513 JSFunction*
function = FindInPrototypeChain<JSFunction>(object, &found_it);
516 if (!function->shared()->is_compiled()) {
531 const AccessorDescriptor Accessors::FunctionLength = {
543 MaybeObject* Accessors::FunctionGetName(
Object*
object,
void*) {
544 bool found_it =
false;
545 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it);
546 if (!found_it)
return HEAP->undefined_value();
547 return holder->shared()->name();
551 const AccessorDescriptor Accessors::FunctionName = {
563 static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
564 JavaScriptFrame* frame,
565 Handle<JSFunction> inlined_function,
566 int inlined_frame_index) {
567 Factory* factory = Isolate::Current()->factory();
568 Vector<SlotRef> args_slots =
569 SlotRef::ComputeSlotMappingForArguments(
572 inlined_function->shared()->formal_parameter_count());
573 int args_count = args_slots.length();
574 Handle<JSObject> arguments =
575 factory->NewArgumentsObject(inlined_function, args_count);
576 Handle<FixedArray> array = factory->NewFixedArray(args_count);
577 for (
int i = 0; i < args_count; ++i) {
578 Handle<Object> value = args_slots[i].GetValue();
579 array->set(i, *value);
581 arguments->set_elements(*array);
582 args_slots.Dispose();
590 Isolate* isolate = Isolate::Current();
592 bool found_it =
false;
593 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it);
594 if (!found_it)
return isolate->
heap()->undefined_value();
597 if (function->shared()->native())
return isolate->
heap()->null_value();
603 for (
int i = functions.length() - 1; i >= 0; i--) {
605 if (functions[i] != *
function)
continue;
612 return ConstructArgumentsObjectForInlinedFunction(frame,
function, i);
615 if (!frame->is_optimized()) {
618 int index = scope_info->StackSlotIndex(
619 isolate->
heap()->arguments_symbol());
622 if (!arguments->IsArgumentsMarker())
return *arguments;
629 it.AdvanceToArgumentsFrame();
640 ASSERT(array->length() == length);
641 for (
int i = 0; i < length; i++) array->set(i, frame->
GetParameter(i));
642 arguments->set_elements(*array);
651 return isolate->
heap()->null_value();
656 FunctionGetArguments,
667 static MaybeObject* CheckNonStrictCallerOrThrow(
669 JSFunction* caller) {
670 DisableAssertNoAllocation enable_allocation;
671 if (!caller->shared()->is_classic_mode()) {
672 return isolate->Throw(
673 *isolate->factory()->NewTypeError(
"strict_caller",
674 HandleVector<Object>(
NULL, 0)));
683 : frame_iterator_(isolate),
689 if (functions_.length() == 0)
return NULL;
690 JSFunction* next_function = functions_[index_];
695 return next_function;
704 next_function =
next();
705 if (next_function ==
function)
return true;
706 }
while (next_function !=
NULL);
711 void GetFunctions() {
712 functions_.Rewind(0);
713 if (frame_iterator_.done())
return;
716 ASSERT(functions_.length() > 0);
717 frame_iterator_.Advance();
718 index_ = functions_.length() - 1;
721 List<JSFunction*> functions_;
726 MaybeObject* Accessors::FunctionGetCaller(
Object*
object,
void*) {
727 Isolate* isolate = Isolate::Current();
728 HandleScope scope(isolate);
729 AssertNoAllocation no_alloc;
730 bool found_it =
false;
731 JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it);
732 if (!found_it)
return isolate->heap()->undefined_value();
733 if (holder->shared()->native())
return isolate->heap()->null_value();
734 Handle<JSFunction>
function(holder, isolate);
736 FrameFunctionIterator it(isolate, no_alloc);
739 if (!it.Find(*
function)) {
741 return isolate->heap()->null_value();
748 if (caller ==
NULL)
return isolate->heap()->null_value();
749 }
while (caller->shared()->is_toplevel());
753 JSFunction* potential_caller = caller;
754 while (potential_caller !=
NULL && potential_caller->IsBuiltin()) {
755 caller = potential_caller;
756 potential_caller = it.next();
761 if (caller->shared()->bound()) {
762 return isolate->heap()->null_value();
764 return CheckNonStrictCallerOrThrow(isolate, caller);
768 const AccessorDescriptor Accessors::FunctionCaller = {
780 MaybeObject* Accessors::ObjectGetPrototype(
Object* receiver,
void*) {
781 Object* current = receiver->GetPrototype();
782 while (current->IsJSObject() &&
784 current = current->GetPrototype();
790 MaybeObject* Accessors::ObjectSetPrototype(JSObject* receiver,
793 const bool skip_hidden_prototypes =
true;
795 return receiver->SetPrototype(value, skip_hidden_prototypes);
799 const AccessorDescriptor Accessors::ObjectPrototype = {
static bool CompileLazy(Handle< JSFunction > function, ClearExceptionFlag flag)
bool Find(JSFunction *function)
static Handle< Object > ToUint32(Handle< Object > obj, bool *exc)
MUST_USE_RESULT MaybeObject * AllocateFunctionPrototype(JSFunction *function)
bool is_hidden_prototype()
static String * cast(Object *obj)
static Smi * FromInt(int value)
static Handle< T > cast(Handle< S > that)
static Failure * Exception()
Object * GetExpression(int index) const
void InitScriptLineEnds(Handle< Script > script)
#define ASSERT(condition)
static Script * cast(Object *obj)
static SharedFunctionInfo * cast(Object *obj)
Handle< JSObject > NewArgumentsObject(Handle< Object > callee, int length)
int ComputeParametersCount() const
static Smi * cast(Object *object)
Handle< JSValue > GetScriptWrapper(Handle< Script > script)
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
static MaybeObject * FunctionGetArguments(Object *object, void *)
static MUST_USE_RESULT MaybeObject * FunctionSetPrototype(JSObject *object, Object *value, void *)
FrameFunctionIterator(Isolate *isolate, const AssertNoAllocation &promise)
JavaScriptFrameIteratorTemp< StackFrameIterator > JavaScriptFrameIterator
virtual void GetFunctions(List< JSFunction * > *functions)
static MUST_USE_RESULT MaybeObject * FunctionGetPrototype(Object *object, void *)
static JSValue * cast(Object *obj)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static Handle< Object > ToNumber(Handle< Object > obj, bool *exc)
static FixedArray * cast(Object *obj)
Object * GetParameter(int index) const
static JSObject * cast(Object *obj)