Commit 28aca51e authored by titzer@chromium.org's avatar titzer@chromium.org

Refactor JavaScriptFrame::function() to return a JSFunction* and remove associated casts.

BUG=

Review URL: https://codereview.chromium.org/18404009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15638 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d1d5f59d
...@@ -565,8 +565,7 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { ...@@ -565,8 +565,7 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
if (info->is_eval()) { if (info->is_eval()) {
StackTraceFrameIterator it(isolate); StackTraceFrameIterator it(isolate);
if (!it.done()) { if (!it.done()) {
script->set_eval_from_shared( script->set_eval_from_shared(it.frame()->function()->shared());
JSFunction::cast(it.frame()->function())->shared());
Code* code = it.frame()->LookupCode(); Code* code = it.frame()->LookupCode();
int offset = static_cast<int>( int offset = static_cast<int>(
it.frame()->pc() - code->instruction_start()); it.frame()->pc() - code->instruction_start());
......
...@@ -965,7 +965,7 @@ Object* Debug::Break(Arguments args) { ...@@ -965,7 +965,7 @@ Object* Debug::Break(Arguments args) {
// Get the debug info (create it if it does not exist). // Get the debug info (create it if it does not exist).
Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo> shared =
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); Handle<SharedFunctionInfo>(frame->function()->shared());
Handle<DebugInfo> debug_info = GetDebugInfo(shared); Handle<DebugInfo> debug_info = GetDebugInfo(shared);
// Find the break point where execution has stopped. // Find the break point where execution has stopped.
...@@ -1348,8 +1348,7 @@ void Debug::FloodHandlerWithOneShot() { ...@@ -1348,8 +1348,7 @@ void Debug::FloodHandlerWithOneShot() {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
if (frame->HasHandler()) { if (frame->HasHandler()) {
// Flood the function with the catch block with break points // Flood the function with the catch block with break points
JSFunction* function = JSFunction::cast(frame->function()); FloodWithOneShot(Handle<JSFunction>(frame->function()));
FloodWithOneShot(Handle<JSFunction>(function));
return; return;
} }
} }
...@@ -1415,13 +1414,13 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { ...@@ -1415,13 +1414,13 @@ void Debug::PrepareStep(StepAction step_action, int step_count) {
// breakpoints. // breakpoints.
frames_it.Advance(); frames_it.Advance();
// Fill the function to return to with one-shot break points. // Fill the function to return to with one-shot break points.
JSFunction* function = JSFunction::cast(frames_it.frame()->function()); JSFunction* function = frames_it.frame()->function();
FloodWithOneShot(Handle<JSFunction>(function)); FloodWithOneShot(Handle<JSFunction>(function));
return; return;
} }
// Get the debug info (create it if it does not exist). // Get the debug info (create it if it does not exist).
Handle<JSFunction> function(JSFunction::cast(frame->function())); Handle<JSFunction> function(frame->function());
Handle<SharedFunctionInfo> shared(function->shared()); Handle<SharedFunctionInfo> shared(function->shared());
if (!EnsureDebugInfo(shared, function)) { if (!EnsureDebugInfo(shared, function)) {
// Return if ensuring debug info failed. // Return if ensuring debug info failed.
...@@ -1486,15 +1485,14 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { ...@@ -1486,15 +1485,14 @@ void Debug::PrepareStep(StepAction step_action, int step_count) {
frames_it.Advance(); frames_it.Advance();
} }
// Skip builtin functions on the stack. // Skip builtin functions on the stack.
while (!frames_it.done() && while (!frames_it.done() && frames_it.frame()->function()->IsBuiltin()) {
JSFunction::cast(frames_it.frame()->function())->IsBuiltin()) {
frames_it.Advance(); frames_it.Advance();
} }
// Step out: If there is a JavaScript caller frame, we need to // Step out: If there is a JavaScript caller frame, we need to
// flood it with breakpoints. // flood it with breakpoints.
if (!frames_it.done()) { if (!frames_it.done()) {
// Fill the function to return to with one-shot break points. // Fill the function to return to with one-shot break points.
JSFunction* function = JSFunction::cast(frames_it.frame()->function()); JSFunction* function = frames_it.frame()->function();
FloodWithOneShot(Handle<JSFunction>(function)); FloodWithOneShot(Handle<JSFunction>(function));
// Set target frame pointer. // Set target frame pointer.
ActivateStepOut(frames_it.frame()); ActivateStepOut(frames_it.frame());
...@@ -1916,7 +1914,7 @@ static void CollectActiveFunctionsFromThread( ...@@ -1916,7 +1914,7 @@ static void CollectActiveFunctionsFromThread(
function->shared()->code()->set_gc_metadata(active_code_marker); function->shared()->code()->set_gc_metadata(active_code_marker);
} }
} else if (frame->function()->IsJSFunction()) { } else if (frame->function()->IsJSFunction()) {
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = frame->function();
ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); ASSERT(frame->LookupCode()->kind() == Code::FUNCTION);
active_functions->Add(Handle<JSFunction>(function)); active_functions->Add(Handle<JSFunction>(function));
function->shared()->code()->set_gc_metadata(active_code_marker); function->shared()->code()->set_gc_metadata(active_code_marker);
...@@ -1933,7 +1931,7 @@ static void RedirectActivationsToRecompiledCodeOnThread( ...@@ -1933,7 +1931,7 @@ static void RedirectActivationsToRecompiledCodeOnThread(
if (frame->is_optimized() || !frame->function()->IsJSFunction()) continue; if (frame->is_optimized() || !frame->function()->IsJSFunction()) continue;
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = frame->function();
ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); ASSERT(frame->LookupCode()->kind() == Code::FUNCTION);
......
...@@ -186,7 +186,7 @@ DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame( ...@@ -186,7 +186,7 @@ DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame(
ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == NULL); ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == NULL);
// Get the function and code from the frame. // Get the function and code from the frame.
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = frame->function();
Code* code = frame->LookupCode(); Code* code = frame->LookupCode();
// Locate the deoptimization point in the code. As we are at a call the // Locate the deoptimization point in the code. As we are at a call the
...@@ -1609,7 +1609,7 @@ void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) { ...@@ -1609,7 +1609,7 @@ void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) {
for (int frame_index = 0; frame_index < jsframe_count(); ++frame_index) { for (int frame_index = 0; frame_index < jsframe_count(); ++frame_index) {
if (frame_index != 0) it->Advance(); if (frame_index != 0) it->Advance();
JavaScriptFrame* frame = it->frame(); JavaScriptFrame* frame = it->frame();
Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate_); Handle<JSFunction> function(frame->function(), isolate_);
Handle<JSObject> arguments; Handle<JSObject> arguments;
for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) { for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
if (frame->GetExpression(i) == isolate_->heap()->arguments_marker()) { if (frame->GetExpression(i) == isolate_->heap()->arguments_marker()) {
......
...@@ -274,10 +274,8 @@ inline bool JavaScriptFrame::has_adapted_arguments() const { ...@@ -274,10 +274,8 @@ inline bool JavaScriptFrame::has_adapted_arguments() const {
} }
inline Object* JavaScriptFrame::function() const { inline JSFunction* JavaScriptFrame::function() const {
Object* result = function_slot_object(); return JSFunction::cast(function_slot_object());
ASSERT(result->IsJSFunction());
return result;
} }
......
...@@ -205,7 +205,7 @@ void StackTraceFrameIterator::Advance() { ...@@ -205,7 +205,7 @@ void StackTraceFrameIterator::Advance() {
bool StackTraceFrameIterator::IsValidFrame() { bool StackTraceFrameIterator::IsValidFrame() {
if (!frame()->function()->IsJSFunction()) return false; if (!frame()->function()->IsJSFunction()) return false;
Object* script = JSFunction::cast(frame()->function())->shared()->script(); Object* script = frame()->function()->shared()->script();
// Don't show functions from native scripts to user. // Don't show functions from native scripts to user.
return (script->IsScript() && return (script->IsScript() &&
Script::TYPE_NATIVE != Script::cast(script)->type()->value()); Script::TYPE_NATIVE != Script::cast(script)->type()->value());
...@@ -724,8 +724,7 @@ int JavaScriptFrame::GetArgumentsLength() const { ...@@ -724,8 +724,7 @@ int JavaScriptFrame::GetArgumentsLength() const {
Code* JavaScriptFrame::unchecked_code() const { Code* JavaScriptFrame::unchecked_code() const {
JSFunction* function = JSFunction::cast(this->function()); return function()->code();
return function->code();
} }
...@@ -733,8 +732,7 @@ int JavaScriptFrame::GetNumberOfIncomingArguments() const { ...@@ -733,8 +732,7 @@ int JavaScriptFrame::GetNumberOfIncomingArguments() const {
ASSERT(can_access_heap_objects() && ASSERT(can_access_heap_objects() &&
isolate()->heap()->gc_state() == Heap::NOT_IN_GC); isolate()->heap()->gc_state() == Heap::NOT_IN_GC);
JSFunction* function = JSFunction::cast(this->function()); return function()->shared()->formal_parameter_count();
return function->shared()->formal_parameter_count();
} }
...@@ -745,7 +743,7 @@ Address JavaScriptFrame::GetCallerStackPointer() const { ...@@ -745,7 +743,7 @@ Address JavaScriptFrame::GetCallerStackPointer() const {
void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) { void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) {
ASSERT(functions->length() == 0); ASSERT(functions->length() == 0);
functions->Add(JSFunction::cast(function())); functions->Add(function());
} }
...@@ -754,7 +752,7 @@ void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { ...@@ -754,7 +752,7 @@ void JavaScriptFrame::Summarize(List<FrameSummary>* functions) {
Code* code_pointer = LookupCode(); Code* code_pointer = LookupCode();
int offset = static_cast<int>(pc() - code_pointer->address()); int offset = static_cast<int>(pc() - code_pointer->address());
FrameSummary summary(receiver(), FrameSummary summary(receiver(),
JSFunction::cast(function()), function(),
code_pointer, code_pointer,
offset, offset,
IsConstructor()); IsConstructor());
...@@ -775,40 +773,35 @@ void JavaScriptFrame::PrintTop(Isolate* isolate, ...@@ -775,40 +773,35 @@ void JavaScriptFrame::PrintTop(Isolate* isolate,
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
if (frame->IsConstructor()) PrintF(file, "new "); if (frame->IsConstructor()) PrintF(file, "new ");
// function name // function name
Object* maybe_fun = frame->function(); JSFunction* fun = frame->function();
if (maybe_fun->IsJSFunction()) { fun->PrintName();
JSFunction* fun = JSFunction::cast(maybe_fun); Code* js_code = frame->unchecked_code();
fun->PrintName(); Address pc = frame->pc();
Code* js_code = frame->unchecked_code(); int code_offset =
Address pc = frame->pc(); static_cast<int>(pc - js_code->instruction_start());
int code_offset = PrintF("+%d", code_offset);
static_cast<int>(pc - js_code->instruction_start()); SharedFunctionInfo* shared = fun->shared();
PrintF("+%d", code_offset); if (print_line_number) {
SharedFunctionInfo* shared = fun->shared(); Code* code = Code::cast(
if (print_line_number) { v8::internal::Isolate::Current()->heap()->FindCodeObject(pc));
Code* code = Code::cast( int source_pos = code->SourcePosition(pc);
v8::internal::Isolate::Current()->heap()->FindCodeObject(pc)); Object* maybe_script = shared->script();
int source_pos = code->SourcePosition(pc); if (maybe_script->IsScript()) {
Object* maybe_script = shared->script(); Handle<Script> script(Script::cast(maybe_script));
if (maybe_script->IsScript()) { int line = GetScriptLineNumberSafe(script, source_pos) + 1;
Handle<Script> script(Script::cast(maybe_script)); Object* script_name_raw = script->name();
int line = GetScriptLineNumberSafe(script, source_pos) + 1; if (script_name_raw->IsString()) {
Object* script_name_raw = script->name(); String* script_name = String::cast(script->name());
if (script_name_raw->IsString()) { SmartArrayPointer<char> c_script_name =
String* script_name = String::cast(script->name()); script_name->ToCString(DISALLOW_NULLS,
SmartArrayPointer<char> c_script_name = ROBUST_STRING_TRAVERSAL);
script_name->ToCString(DISALLOW_NULLS, PrintF(file, " at %s:%d", *c_script_name, line);
ROBUST_STRING_TRAVERSAL);
PrintF(file, " at %s:%d", *c_script_name, line);
} else {
PrintF(file, " at <unknown>:%d", line);
}
} else { } else {
PrintF(file, " at <unknown>:<unknown>"); PrintF(file, " at <unknown>:%d", line);
} }
} else {
PrintF(file, " at <unknown>:<unknown>");
} }
} else {
PrintF("<unknown>");
} }
if (print_args) { if (print_args) {
...@@ -913,7 +906,7 @@ void FrameSummary::Print() { ...@@ -913,7 +906,7 @@ void FrameSummary::Print() {
JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array, JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array,
int literal_id) { int literal_id) {
if (literal_id == Translation::kSelfLiteralId) { if (literal_id == Translation::kSelfLiteralId) {
return JSFunction::cast(function()); return function();
} }
return JSFunction::cast(literal_array->get(literal_id)); return JSFunction::cast(literal_array->get(literal_id));
...@@ -1018,7 +1011,7 @@ DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( ...@@ -1018,7 +1011,7 @@ DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData(
int* deopt_index) { int* deopt_index) {
ASSERT(is_optimized()); ASSERT(is_optimized());
JSFunction* opt_function = JSFunction::cast(function()); JSFunction* opt_function = function();
Code* code = opt_function->code(); Code* code = opt_function->code();
// The code object may have been replaced by lazy deoptimization. Fall // The code object may have been replaced by lazy deoptimization. Fall
...@@ -1132,7 +1125,7 @@ void JavaScriptFrame::Print(StringStream* accumulator, ...@@ -1132,7 +1125,7 @@ void JavaScriptFrame::Print(StringStream* accumulator,
int index) const { int index) const {
HandleScope scope(isolate()); HandleScope scope(isolate());
Object* receiver = this->receiver(); Object* receiver = this->receiver();
Object* function = this->function(); JSFunction* function = this->function();
accumulator->PrintSecurityTokenIfChanged(function); accumulator->PrintSecurityTokenIfChanged(function);
PrintIndex(accumulator, mode, index); PrintIndex(accumulator, mode, index);
...@@ -1146,29 +1139,27 @@ void JavaScriptFrame::Print(StringStream* accumulator, ...@@ -1146,29 +1139,27 @@ void JavaScriptFrame::Print(StringStream* accumulator,
// or context slots. // or context slots.
Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate()));
if (function->IsJSFunction()) { Handle<SharedFunctionInfo> shared(function->shared());
Handle<SharedFunctionInfo> shared(JSFunction::cast(function)->shared()); scope_info = Handle<ScopeInfo>(shared->scope_info());
scope_info = Handle<ScopeInfo>(shared->scope_info()); Object* script_obj = shared->script();
Object* script_obj = shared->script(); if (script_obj->IsScript()) {
if (script_obj->IsScript()) { Handle<Script> script(Script::cast(script_obj));
Handle<Script> script(Script::cast(script_obj)); accumulator->Add(" [");
accumulator->Add(" ["); accumulator->PrintName(script->name());
accumulator->PrintName(script->name());
Address pc = this->pc();
Address pc = this->pc(); if (code != NULL && code->kind() == Code::FUNCTION &&
if (code != NULL && code->kind() == Code::FUNCTION && pc >= code->instruction_start() && pc < code->instruction_end()) {
pc >= code->instruction_start() && pc < code->instruction_end()) { int source_pos = code->SourcePosition(pc);
int source_pos = code->SourcePosition(pc); int line = GetScriptLineNumberSafe(script, source_pos) + 1;
int line = GetScriptLineNumberSafe(script, source_pos) + 1; accumulator->Add(":%d", line);
accumulator->Add(":%d", line); } else {
} else { int function_start_pos = shared->start_position();
int function_start_pos = shared->start_position(); int line = GetScriptLineNumberSafe(script, function_start_pos) + 1;
int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; accumulator->Add(":~%d", line);
accumulator->Add(":~%d", line);
}
accumulator->Add("] ");
} }
accumulator->Add("] ");
} }
accumulator->Add("(this=%o", receiver); accumulator->Add("(this=%o", receiver);
...@@ -1258,7 +1249,7 @@ void JavaScriptFrame::Print(StringStream* accumulator, ...@@ -1258,7 +1249,7 @@ void JavaScriptFrame::Print(StringStream* accumulator,
// Print details about the function. // Print details about the function.
if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
SharedFunctionInfo* shared = JSFunction::cast(function)->shared(); SharedFunctionInfo* shared = function->shared();
accumulator->Add("--------- s o u r c e c o d e ---------\n"); accumulator->Add("--------- s o u r c e c o d e ---------\n");
shared->SourceCodePrint(accumulator, FLAG_max_stack_trace_source_length); shared->SourceCodePrint(accumulator, FLAG_max_stack_trace_source_length);
accumulator->Add("\n-----------------------------------------\n"); accumulator->Add("\n-----------------------------------------\n");
...@@ -1273,10 +1264,8 @@ void ArgumentsAdaptorFrame::Print(StringStream* accumulator, ...@@ -1273,10 +1264,8 @@ void ArgumentsAdaptorFrame::Print(StringStream* accumulator,
int index) const { int index) const {
int actual = ComputeParametersCount(); int actual = ComputeParametersCount();
int expected = -1; int expected = -1;
Object* function = this->function(); JSFunction* function = this->function();
if (function->IsJSFunction()) { expected = function->shared()->formal_parameter_count();
expected = JSFunction::cast(function)->shared()->formal_parameter_count();
}
PrintIndex(accumulator, mode, index); PrintIndex(accumulator, mode, index);
accumulator->Add("arguments adaptor frame: %d->%d", actual, expected); accumulator->Add("arguments adaptor frame: %d->%d", actual, expected);
......
...@@ -543,7 +543,7 @@ class JavaScriptFrame: public StandardFrame { ...@@ -543,7 +543,7 @@ class JavaScriptFrame: public StandardFrame {
virtual Type type() const { return JAVA_SCRIPT; } virtual Type type() const { return JAVA_SCRIPT; }
// Accessors. // Accessors.
inline Object* function() const; inline JSFunction* function() const;
inline Object* receiver() const; inline Object* receiver() const;
inline void set_receiver(Object* value); inline void set_receiver(Object* value);
......
...@@ -159,7 +159,7 @@ Address IC::OriginalCodeAddress() const { ...@@ -159,7 +159,7 @@ Address IC::OriginalCodeAddress() const {
JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame()); JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame());
// Find the function on the stack and both the active code for the // Find the function on the stack and both the active code for the
// function and the original code. // function and the original code.
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = frame->function();
Handle<SharedFunctionInfo> shared(function->shared(), isolate()); Handle<SharedFunctionInfo> shared(function->shared(), isolate());
Code* code = shared->code(); Code* code = shared->code();
ASSERT(Debug::HasDebugInfo(shared)); ASSERT(Debug::HasDebugInfo(shared));
......
...@@ -622,10 +622,8 @@ static bool IsVisibleInStackTrace(StackFrame* raw_frame, ...@@ -622,10 +622,8 @@ static bool IsVisibleInStackTrace(StackFrame* raw_frame,
// Only display JS frames. // Only display JS frames.
if (!raw_frame->is_java_script()) return false; if (!raw_frame->is_java_script()) return false;
JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
Object* raw_fun = frame->function(); JSFunction* fun = frame->function();
// Not sure when this can happen but skip it just in case. if ((fun == caller) && !(*seen_caller)) {
if (!raw_fun->IsJSFunction()) return false;
if ((raw_fun == caller) && !(*seen_caller)) {
*seen_caller = true; *seen_caller = true;
return false; return false;
} }
...@@ -637,7 +635,6 @@ static bool IsVisibleInStackTrace(StackFrame* raw_frame, ...@@ -637,7 +635,6 @@ static bool IsVisibleInStackTrace(StackFrame* raw_frame,
// The --builtins-in-stack-traces command line flag allows including // The --builtins-in-stack-traces command line flag allows including
// internal call sites in the stack trace for debugging purposes. // internal call sites in the stack trace for debugging purposes.
if (!FLAG_builtins_in_stack_traces) { if (!FLAG_builtins_in_stack_traces) {
JSFunction* fun = JSFunction::cast(raw_fun);
if (frame->receiver()->IsJSBuiltinsObject() || if (frame->receiver()->IsJSBuiltinsObject() ||
(fun->IsBuiltin() && !fun->shared()->native())) { (fun->IsBuiltin() && !fun->shared()->native())) {
return false; return false;
...@@ -1201,7 +1198,7 @@ void Isolate::PrintCurrentStackTrace(FILE* out) { ...@@ -1201,7 +1198,7 @@ void Isolate::PrintCurrentStackTrace(FILE* out) {
int pos = frame->LookupCode()->SourcePosition(frame->pc()); int pos = frame->LookupCode()->SourcePosition(frame->pc());
Handle<Object> pos_obj(Smi::FromInt(pos), this); Handle<Object> pos_obj(Smi::FromInt(pos), this);
// Fetch function and receiver. // Fetch function and receiver.
Handle<JSFunction> fun(JSFunction::cast(frame->function())); Handle<JSFunction> fun(frame->function());
Handle<Object> recv(frame->receiver(), this); Handle<Object> recv(frame->receiver(), this);
// Advance to the next JavaScript frame and determine if the // Advance to the next JavaScript frame and determine if the
// current frame is the top-level frame. // current frame is the top-level frame.
...@@ -1225,7 +1222,7 @@ void Isolate::ComputeLocation(MessageLocation* target) { ...@@ -1225,7 +1222,7 @@ void Isolate::ComputeLocation(MessageLocation* target) {
StackTraceFrameIterator it(this); StackTraceFrameIterator it(this);
if (!it.done()) { if (!it.done()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction* fun = JSFunction::cast(frame->function()); JSFunction* fun = frame->function();
Object* script = fun->shared()->script(); Object* script = fun->shared()->script();
if (script->IsScript() && if (script->IsScript() &&
!(Script::cast(script)->source()->IsUndefined())) { !(Script::cast(script)->source()->IsUndefined())) {
......
...@@ -1621,8 +1621,7 @@ static bool CheckActivation(Handle<JSArray> shared_info_array, ...@@ -1621,8 +1621,7 @@ static bool CheckActivation(Handle<JSArray> shared_info_array,
LiveEdit::FunctionPatchabilityStatus status) { LiveEdit::FunctionPatchabilityStatus status) {
if (!frame->is_java_script()) return false; if (!frame->is_java_script()) return false;
Handle<JSFunction> function( Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function());
JSFunction::cast(JavaScriptFrame::cast(frame)->function()));
Isolate* isolate = shared_info_array->GetIsolate(); Isolate* isolate = shared_info_array->GetIsolate();
int len = GetArrayLength(shared_info_array); int len = GetArrayLength(shared_info_array);
......
...@@ -247,7 +247,7 @@ void RuntimeProfiler::OptimizeNow() { ...@@ -247,7 +247,7 @@ void RuntimeProfiler::OptimizeNow() {
frame_count++ < frame_count_limit && !it.done(); frame_count++ < frame_count_limit && !it.done();
it.Advance()) { it.Advance()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = frame->function();
if (!FLAG_watch_ic_patching) { if (!FLAG_watch_ic_patching) {
// Adjust threshold each time we have processed // Adjust threshold each time we have processed
......
...@@ -2797,7 +2797,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) { ...@@ -2797,7 +2797,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) {
JavaScriptFrameIterator it(isolate); JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = frame->function();
RUNTIME_ASSERT(function->shared()->is_generator()); RUNTIME_ASSERT(function->shared()->is_generator());
JSGeneratorObject* generator; JSGeneratorObject* generator;
...@@ -2826,8 +2826,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SuspendJSGeneratorObject) { ...@@ -2826,8 +2826,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SuspendJSGeneratorObject) {
JavaScriptFrameIterator stack_iterator(isolate); JavaScriptFrameIterator stack_iterator(isolate);
JavaScriptFrame* frame = stack_iterator.frame(); JavaScriptFrame* frame = stack_iterator.frame();
RUNTIME_ASSERT(JSFunction::cast(frame->function())->shared()->is_generator()); RUNTIME_ASSERT(frame->function()->shared()->is_generator());
ASSERT_EQ(JSFunction::cast(frame->function()), generator_object->function()); ASSERT_EQ(frame->function(), generator_object->function());
// The caller should have saved the context and continuation already. // The caller should have saved the context and continuation already.
ASSERT_EQ(generator_object->context(), Context::cast(frame->context())); ASSERT_EQ(generator_object->context(), Context::cast(frame->context()));
...@@ -5732,9 +5732,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { ...@@ -5732,9 +5732,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
// Handle special arguments properties. // Handle special arguments properties.
if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n);
if (key->Equals(isolate->heap()->callee_string())) { if (key->Equals(isolate->heap()->callee_string())) {
Object* function = frame->function(); JSFunction* function = frame->function();
if (function->IsJSFunction() && if (!function->shared()->is_classic_mode()) {
!JSFunction::cast(function)->shared()->is_classic_mode()) {
return isolate->Throw(*isolate->factory()->NewTypeError( return isolate->Throw(*isolate->factory()->NewTypeError(
"strict_arguments_callee", HandleVector<Object>(NULL, 0))); "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
} }
...@@ -8221,7 +8220,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { ...@@ -8221,7 +8220,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
RUNTIME_ASSERT(frame->function()->IsJSFunction()); RUNTIME_ASSERT(frame->function()->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); Handle<JSFunction> function(frame->function(), isolate);
Handle<Code> optimized_code(function->code()); Handle<Code> optimized_code(function->code());
RUNTIME_ASSERT((type != Deoptimizer::EAGER && RUNTIME_ASSERT((type != Deoptimizer::EAGER &&
type != Deoptimizer::SOFT) || function->IsOptimized()); type != Deoptimizer::SOFT) || function->IsOptimized());
...@@ -8237,7 +8236,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { ...@@ -8237,7 +8236,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
bool has_other_activations = false; bool has_other_activations = false;
while (!it.done()) { while (!it.done()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction* other_function = JSFunction::cast(frame->function()); JSFunction* other_function = frame->function();
if (frame->is_optimized() && other_function->code() == function->code()) { if (frame->is_optimized() && other_function->code() == function->code()) {
has_other_activations = true; has_other_activations = true;
break; break;
...@@ -8353,8 +8352,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimize) { ...@@ -8353,8 +8352,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimize) {
// Disable optimization for the calling function. // Disable optimization for the calling function.
JavaScriptFrameIterator it(isolate); JavaScriptFrameIterator it(isolate);
if (!it.done()) { if (!it.done()) {
JSFunction *function = JSFunction::cast(it.frame()->function()); it.frame()->function()->shared()->set_optimization_disabled(true);
function->shared()->set_optimization_disabled(true);
} }
return isolate->heap()->undefined_value(); return isolate->heap()->undefined_value();
} }
...@@ -11235,7 +11233,7 @@ static bool SetLocalVariableValue(Isolate* isolate, ...@@ -11235,7 +11233,7 @@ static bool SetLocalVariableValue(Isolate* isolate,
return false; return false;
} }
Handle<JSFunction> function(JSFunction::cast(frame->function())); Handle<JSFunction> function(frame->function());
Handle<SharedFunctionInfo> shared(function->shared()); Handle<SharedFunctionInfo> shared(function->shared());
Handle<ScopeInfo> scope_info(shared->scope_info()); Handle<ScopeInfo> scope_info(shared->scope_info());
...@@ -11482,7 +11480,7 @@ class ScopeIterator { ...@@ -11482,7 +11480,7 @@ class ScopeIterator {
: isolate_(isolate), : isolate_(isolate),
frame_(frame), frame_(frame),
inlined_jsframe_index_(inlined_jsframe_index), inlined_jsframe_index_(inlined_jsframe_index),
function_(JSFunction::cast(frame->function())), function_(frame->function()),
context_(Context::cast(frame->context())), context_(Context::cast(frame->context())),
nested_scope_chain_(4), nested_scope_chain_(4),
failed_(false) { failed_(false) {
...@@ -11863,7 +11861,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetStepInPositions) { ...@@ -11863,7 +11861,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetStepInPositions) {
JavaScriptFrame* frame = frame_it.frame(); JavaScriptFrame* frame = frame_it.frame();
Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo> shared =
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); Handle<SharedFunctionInfo>(frame->function()->shared());
Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared); Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared);
int len = 0; int len = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment