Revision: 15638
Author: [email protected]
Date: Thu Jul 11 09:45:58 2013
Log: Refactor JavaScriptFrame::function() to return a JSFunction* and
remove associated casts.
BUG=
Review URL: https://codereview.chromium.org/18404009
http://code.google.com/p/v8/source/detail?r=15638
Modified:
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/src/deoptimizer.cc
/branches/bleeding_edge/src/frames-inl.h
/branches/bleeding_edge/src/frames.cc
/branches/bleeding_edge/src/frames.h
/branches/bleeding_edge/src/ic.cc
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/liveedit.cc
/branches/bleeding_edge/src/runtime-profiler.cc
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/compiler.cc Sun Jul 7 04:42:30 2013
+++ /branches/bleeding_edge/src/compiler.cc Thu Jul 11 09:45:58 2013
@@ -565,8 +565,7 @@
if (info->is_eval()) {
StackTraceFrameIterator it(isolate);
if (!it.done()) {
- script->set_eval_from_shared(
- JSFunction::cast(it.frame()->function())->shared());
+ script->set_eval_from_shared(it.frame()->function()->shared());
Code* code = it.frame()->LookupCode();
int offset = static_cast<int>(
it.frame()->pc() - code->instruction_start());
=======================================
--- /branches/bleeding_edge/src/debug.cc Fri Jul 5 02:52:11 2013
+++ /branches/bleeding_edge/src/debug.cc Thu Jul 11 09:45:58 2013
@@ -965,7 +965,7 @@
// Get the debug info (create it if it does not exist).
Handle<SharedFunctionInfo> shared =
-
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
+ Handle<SharedFunctionInfo>(frame->function()->shared());
Handle<DebugInfo> debug_info = GetDebugInfo(shared);
// Find the break point where execution has stopped.
@@ -1348,8 +1348,7 @@
JavaScriptFrame* frame = it.frame();
if (frame->HasHandler()) {
// Flood the function with the catch block with break points
- JSFunction* function = JSFunction::cast(frame->function());
- FloodWithOneShot(Handle<JSFunction>(function));
+ FloodWithOneShot(Handle<JSFunction>(frame->function()));
return;
}
}
@@ -1415,13 +1414,13 @@
// breakpoints.
frames_it.Advance();
// 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));
return;
}
// 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());
if (!EnsureDebugInfo(shared, function)) {
// Return if ensuring debug info failed.
@@ -1486,15 +1485,14 @@
frames_it.Advance();
}
// Skip builtin functions on the stack.
- while (!frames_it.done() &&
- JSFunction::cast(frames_it.frame()->function())->IsBuiltin()) {
+ while (!frames_it.done() &&
frames_it.frame()->function()->IsBuiltin()) {
frames_it.Advance();
}
// Step out: If there is a JavaScript caller frame, we need to
// flood it with breakpoints.
if (!frames_it.done()) {
// 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));
// Set target frame pointer.
ActivateStepOut(frames_it.frame());
@@ -1916,7 +1914,7 @@
function->shared()->code()->set_gc_metadata(active_code_marker);
}
} else if (frame->function()->IsJSFunction()) {
- JSFunction* function = JSFunction::cast(frame->function());
+ JSFunction* function = frame->function();
ASSERT(frame->LookupCode()->kind() == Code::FUNCTION);
active_functions->Add(Handle<JSFunction>(function));
function->shared()->code()->set_gc_metadata(active_code_marker);
@@ -1933,7 +1931,7 @@
if (frame->is_optimized() || !frame->function()->IsJSFunction())
continue;
- JSFunction* function = JSFunction::cast(frame->function());
+ JSFunction* function = frame->function();
ASSERT(frame->LookupCode()->kind() == Code::FUNCTION);
=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc Wed Jul 3 03:10:27 2013
+++ /branches/bleeding_edge/src/deoptimizer.cc Thu Jul 11 09:45:58 2013
@@ -186,7 +186,7 @@
ASSERT(isolate->deoptimizer_data()->deoptimized_frame_info_ == NULL);
// Get the function and code from the frame.
- JSFunction* function = JSFunction::cast(frame->function());
+ JSFunction* function = frame->function();
Code* code = frame->LookupCode();
// Locate the deoptimization point in the code. As we are at a call the
@@ -1609,7 +1609,7 @@
for (int frame_index = 0; frame_index < jsframe_count(); ++frame_index) {
if (frame_index != 0) it->Advance();
JavaScriptFrame* frame = it->frame();
- Handle<JSFunction> function(JSFunction::cast(frame->function()),
isolate_);
+ Handle<JSFunction> function(frame->function(), isolate_);
Handle<JSObject> arguments;
for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
if (frame->GetExpression(i) == isolate_->heap()->arguments_marker())
{
=======================================
--- /branches/bleeding_edge/src/frames-inl.h Fri Jun 28 06:40:41 2013
+++ /branches/bleeding_edge/src/frames-inl.h Thu Jul 11 09:45:58 2013
@@ -274,10 +274,8 @@
}
-inline Object* JavaScriptFrame::function() const {
- Object* result = function_slot_object();
- ASSERT(result->IsJSFunction());
- return result;
+inline JSFunction* JavaScriptFrame::function() const {
+ return JSFunction::cast(function_slot_object());
}
=======================================
--- /branches/bleeding_edge/src/frames.cc Fri Jul 5 02:52:11 2013
+++ /branches/bleeding_edge/src/frames.cc Thu Jul 11 09:45:58 2013
@@ -205,7 +205,7 @@
bool StackTraceFrameIterator::IsValidFrame() {
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.
return (script->IsScript() &&
Script::TYPE_NATIVE != Script::cast(script)->type()->value());
@@ -724,8 +724,7 @@
Code* JavaScriptFrame::unchecked_code() const {
- JSFunction* function = JSFunction::cast(this->function());
- return function->code();
+ return function()->code();
}
@@ -733,8 +732,7 @@
ASSERT(can_access_heap_objects() &&
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 @@
void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) {
ASSERT(functions->length() == 0);
- functions->Add(JSFunction::cast(function()));
+ functions->Add(function());
}
@@ -754,7 +752,7 @@
Code* code_pointer = LookupCode();
int offset = static_cast<int>(pc() - code_pointer->address());
FrameSummary summary(receiver(),
- JSFunction::cast(function()),
+ function(),
code_pointer,
offset,
IsConstructor());
@@ -775,40 +773,35 @@
JavaScriptFrame* frame = it.frame();
if (frame->IsConstructor()) PrintF(file, "new ");
// function name
- Object* maybe_fun = frame->function();
- if (maybe_fun->IsJSFunction()) {
- JSFunction* fun = JSFunction::cast(maybe_fun);
- fun->PrintName();
- Code* js_code = frame->unchecked_code();
- Address pc = frame->pc();
- int code_offset =
- static_cast<int>(pc - js_code->instruction_start());
- PrintF("+%d", code_offset);
- SharedFunctionInfo* shared = fun->shared();
- if (print_line_number) {
- Code* code = Code::cast(
-
v8::internal::Isolate::Current()->heap()->FindCodeObject(pc));
- int source_pos = code->SourcePosition(pc);
- Object* maybe_script = shared->script();
- if (maybe_script->IsScript()) {
- Handle<Script> script(Script::cast(maybe_script));
- int line = GetScriptLineNumberSafe(script, source_pos) + 1;
- Object* script_name_raw = script->name();
- if (script_name_raw->IsString()) {
- String* script_name = String::cast(script->name());
- SmartArrayPointer<char> c_script_name =
- script_name->ToCString(DISALLOW_NULLS,
- ROBUST_STRING_TRAVERSAL);
- PrintF(file, " at %s:%d", *c_script_name, line);
- } else {
- PrintF(file, " at <unknown>:%d", line);
- }
+ JSFunction* fun = frame->function();
+ fun->PrintName();
+ Code* js_code = frame->unchecked_code();
+ Address pc = frame->pc();
+ int code_offset =
+ static_cast<int>(pc - js_code->instruction_start());
+ PrintF("+%d", code_offset);
+ SharedFunctionInfo* shared = fun->shared();
+ if (print_line_number) {
+ Code* code = Code::cast(
+ v8::internal::Isolate::Current()->heap()->FindCodeObject(pc));
+ int source_pos = code->SourcePosition(pc);
+ Object* maybe_script = shared->script();
+ if (maybe_script->IsScript()) {
+ Handle<Script> script(Script::cast(maybe_script));
+ int line = GetScriptLineNumberSafe(script, source_pos) + 1;
+ Object* script_name_raw = script->name();
+ if (script_name_raw->IsString()) {
+ String* script_name = String::cast(script->name());
+ SmartArrayPointer<char> c_script_name =
+ script_name->ToCString(DISALLOW_NULLS,
+ ROBUST_STRING_TRAVERSAL);
+ PrintF(file, " at %s:%d", *c_script_name, line);
} else {
- PrintF(file, " at <unknown>:<unknown>");
+ PrintF(file, " at <unknown>:%d", line);
}
+ } else {
+ PrintF(file, " at <unknown>:<unknown>");
}
- } else {
- PrintF("<unknown>");
}
if (print_args) {
@@ -913,7 +906,7 @@
JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array,
int literal_id) {
if (literal_id == Translation::kSelfLiteralId) {
- return JSFunction::cast(function());
+ return function();
}
return JSFunction::cast(literal_array->get(literal_id));
@@ -1018,7 +1011,7 @@
int* deopt_index) {
ASSERT(is_optimized());
- JSFunction* opt_function = JSFunction::cast(function());
+ JSFunction* opt_function = function();
Code* code = opt_function->code();
// The code object may have been replaced by lazy deoptimization. Fall
@@ -1132,7 +1125,7 @@
int index) const {
HandleScope scope(isolate());
Object* receiver = this->receiver();
- Object* function = this->function();
+ JSFunction* function = this->function();
accumulator->PrintSecurityTokenIfChanged(function);
PrintIndex(accumulator, mode, index);
@@ -1146,29 +1139,27 @@
// or context slots.
Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate()));
- if (function->IsJSFunction()) {
- Handle<SharedFunctionInfo>
shared(JSFunction::cast(function)->shared());
- scope_info = Handle<ScopeInfo>(shared->scope_info());
- Object* script_obj = shared->script();
- if (script_obj->IsScript()) {
- Handle<Script> script(Script::cast(script_obj));
- accumulator->Add(" [");
- accumulator->PrintName(script->name());
+ Handle<SharedFunctionInfo> shared(function->shared());
+ scope_info = Handle<ScopeInfo>(shared->scope_info());
+ Object* script_obj = shared->script();
+ if (script_obj->IsScript()) {
+ Handle<Script> script(Script::cast(script_obj));
+ accumulator->Add(" [");
+ accumulator->PrintName(script->name());
- Address pc = this->pc();
- if (code != NULL && code->kind() == Code::FUNCTION &&
- pc >= code->instruction_start() && pc < code->instruction_end())
{
- int source_pos = code->SourcePosition(pc);
- int line = GetScriptLineNumberSafe(script, source_pos) + 1;
- accumulator->Add(":%d", line);
- } else {
- int function_start_pos = shared->start_position();
- int line = GetScriptLineNumberSafe(script, function_start_pos) + 1;
- accumulator->Add(":~%d", line);
- }
+ Address pc = this->pc();
+ if (code != NULL && code->kind() == Code::FUNCTION &&
+ pc >= code->instruction_start() && pc < code->instruction_end()) {
+ int source_pos = code->SourcePosition(pc);
+ int line = GetScriptLineNumberSafe(script, source_pos) + 1;
+ accumulator->Add(":%d", line);
+ } else {
+ int function_start_pos = shared->start_position();
+ int line = GetScriptLineNumberSafe(script, function_start_pos) + 1;
+ accumulator->Add(":~%d", line);
+ }
- accumulator->Add("] ");
- }
+ accumulator->Add("] ");
}
accumulator->Add("(this=%o", receiver);
@@ -1258,7 +1249,7 @@
// Print details about the function.
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");
shared->SourceCodePrint(accumulator,
FLAG_max_stack_trace_source_length);
accumulator->Add("\n-----------------------------------------\n");
@@ -1273,10 +1264,8 @@
int index) const {
int actual = ComputeParametersCount();
int expected = -1;
- Object* function = this->function();
- if (function->IsJSFunction()) {
- expected =
JSFunction::cast(function)->shared()->formal_parameter_count();
- }
+ JSFunction* function = this->function();
+ expected = function->shared()->formal_parameter_count();
PrintIndex(accumulator, mode, index);
accumulator->Add("arguments adaptor frame: %d->%d", actual, expected);
=======================================
--- /branches/bleeding_edge/src/frames.h Wed Jul 3 09:20:59 2013
+++ /branches/bleeding_edge/src/frames.h Thu Jul 11 09:45:58 2013
@@ -543,7 +543,7 @@
virtual Type type() const { return JAVA_SCRIPT; }
// Accessors.
- inline Object* function() const;
+ inline JSFunction* function() const;
inline Object* receiver() const;
inline void set_receiver(Object* value);
=======================================
--- /branches/bleeding_edge/src/ic.cc Thu Jul 11 09:25:58 2013
+++ /branches/bleeding_edge/src/ic.cc Thu Jul 11 09:45:58 2013
@@ -159,7 +159,7 @@
JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame());
// Find the function on the stack and both the active code for the
// function and the original code.
- JSFunction* function = JSFunction::cast(frame->function());
+ JSFunction* function = frame->function();
Handle<SharedFunctionInfo> shared(function->shared(), isolate());
Code* code = shared->code();
ASSERT(Debug::HasDebugInfo(shared));
=======================================
--- /branches/bleeding_edge/src/isolate.cc Fri Jul 5 05:52:20 2013
+++ /branches/bleeding_edge/src/isolate.cc Thu Jul 11 09:45:58 2013
@@ -622,10 +622,8 @@
// Only display JS frames.
if (!raw_frame->is_java_script()) return false;
JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
- Object* raw_fun = frame->function();
- // Not sure when this can happen but skip it just in case.
- if (!raw_fun->IsJSFunction()) return false;
- if ((raw_fun == caller) && !(*seen_caller)) {
+ JSFunction* fun = frame->function();
+ if ((fun == caller) && !(*seen_caller)) {
*seen_caller = true;
return false;
}
@@ -637,7 +635,6 @@
// The --builtins-in-stack-traces command line flag allows including
// internal call sites in the stack trace for debugging purposes.
if (!FLAG_builtins_in_stack_traces) {
- JSFunction* fun = JSFunction::cast(raw_fun);
if (frame->receiver()->IsJSBuiltinsObject() ||
(fun->IsBuiltin() && !fun->shared()->native())) {
return false;
@@ -1201,7 +1198,7 @@
int pos = frame->LookupCode()->SourcePosition(frame->pc());
Handle<Object> pos_obj(Smi::FromInt(pos), this);
// Fetch function and receiver.
- Handle<JSFunction> fun(JSFunction::cast(frame->function()));
+ Handle<JSFunction> fun(frame->function());
Handle<Object> recv(frame->receiver(), this);
// Advance to the next JavaScript frame and determine if the
// current frame is the top-level frame.
@@ -1225,7 +1222,7 @@
StackTraceFrameIterator it(this);
if (!it.done()) {
JavaScriptFrame* frame = it.frame();
- JSFunction* fun = JSFunction::cast(frame->function());
+ JSFunction* fun = frame->function();
Object* script = fun->shared()->script();
if (script->IsScript() &&
!(Script::cast(script)->source()->IsUndefined())) {
=======================================
--- /branches/bleeding_edge/src/liveedit.cc Fri Jul 5 02:52:11 2013
+++ /branches/bleeding_edge/src/liveedit.cc Thu Jul 11 09:45:58 2013
@@ -1621,8 +1621,7 @@
LiveEdit::FunctionPatchabilityStatus status) {
if (!frame->is_java_script()) return false;
- Handle<JSFunction> function(
- JSFunction::cast(JavaScriptFrame::cast(frame)->function()));
+ Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function());
Isolate* isolate = shared_info_array->GetIsolate();
int len = GetArrayLength(shared_info_array);
=======================================
--- /branches/bleeding_edge/src/runtime-profiler.cc Tue Jul 2 08:30:33 2013
+++ /branches/bleeding_edge/src/runtime-profiler.cc Thu Jul 11 09:45:58 2013
@@ -247,7 +247,7 @@
frame_count++ < frame_count_limit && !it.done();
it.Advance()) {
JavaScriptFrame* frame = it.frame();
- JSFunction* function = JSFunction::cast(frame->function());
+ JSFunction* function = frame->function();
if (!FLAG_watch_ic_patching) {
// Adjust threshold each time we have processed
=======================================
--- /branches/bleeding_edge/src/runtime.cc Thu Jul 11 07:17:56 2013
+++ /branches/bleeding_edge/src/runtime.cc Thu Jul 11 09:45:58 2013
@@ -2797,7 +2797,7 @@
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
- JSFunction* function = JSFunction::cast(frame->function());
+ JSFunction* function = frame->function();
RUNTIME_ASSERT(function->shared()->is_generator());
JSGeneratorObject* generator;
@@ -2826,8 +2826,8 @@
JavaScriptFrameIterator stack_iterator(isolate);
JavaScriptFrame* frame = stack_iterator.frame();
-
RUNTIME_ASSERT(JSFunction::cast(frame->function())->shared()->is_generator());
- ASSERT_EQ(JSFunction::cast(frame->function()),
generator_object->function());
+ RUNTIME_ASSERT(frame->function()->shared()->is_generator());
+ ASSERT_EQ(frame->function(), generator_object->function());
// The caller should have saved the context and continuation already.
ASSERT_EQ(generator_object->context(), Context::cast(frame->context()));
@@ -5732,9 +5732,8 @@
// Handle special arguments properties.
if (key->Equals(isolate->heap()->length_string())) return
Smi::FromInt(n);
if (key->Equals(isolate->heap()->callee_string())) {
- Object* function = frame->function();
- if (function->IsJSFunction() &&
- !JSFunction::cast(function)->shared()->is_classic_mode()) {
+ JSFunction* function = frame->function();
+ if (!function->shared()->is_classic_mode()) {
return isolate->Throw(*isolate->factory()->NewTypeError(
"strict_arguments_callee", HandleVector<Object>(NULL, 0)));
}
@@ -8221,7 +8220,7 @@
JavaScriptFrame* frame = it.frame();
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());
RUNTIME_ASSERT((type != Deoptimizer::EAGER &&
type != Deoptimizer::SOFT) || function->IsOptimized());
@@ -8237,7 +8236,7 @@
bool has_other_activations = false;
while (!it.done()) {
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()) {
has_other_activations = true;
break;
@@ -8353,8 +8352,7 @@
// Disable optimization for the calling function.
JavaScriptFrameIterator it(isolate);
if (!it.done()) {
- JSFunction *function = JSFunction::cast(it.frame()->function());
- function->shared()->set_optimization_disabled(true);
+ it.frame()->function()->shared()->set_optimization_disabled(true);
}
return isolate->heap()->undefined_value();
}
@@ -11235,7 +11233,7 @@
return false;
}
- Handle<JSFunction> function(JSFunction::cast(frame->function()));
+ Handle<JSFunction> function(frame->function());
Handle<SharedFunctionInfo> shared(function->shared());
Handle<ScopeInfo> scope_info(shared->scope_info());
@@ -11482,7 +11480,7 @@
: isolate_(isolate),
frame_(frame),
inlined_jsframe_index_(inlined_jsframe_index),
- function_(JSFunction::cast(frame->function())),
+ function_(frame->function()),
context_(Context::cast(frame->context())),
nested_scope_chain_(4),
failed_(false) {
@@ -11863,7 +11861,7 @@
JavaScriptFrame* frame = frame_it.frame();
Handle<SharedFunctionInfo> shared =
-
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
+ Handle<SharedFunctionInfo>(frame->function()->shared());
Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared);
int len = 0;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.