diff options
Diffstat (limited to 'chromium/v8/src/frames.cc')
-rw-r--r-- | chromium/v8/src/frames.cc | 124 |
1 files changed, 53 insertions, 71 deletions
diff --git a/chromium/v8/src/frames.cc b/chromium/v8/src/frames.cc index 9549c2db653..7e0079bcf62 100644 --- a/chromium/v8/src/frames.cc +++ b/chromium/v8/src/frames.cc @@ -1,42 +1,18 @@ // Copyright 2012 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "v8.h" - -#include "ast.h" -#include "deoptimizer.h" -#include "frames-inl.h" -#include "full-codegen.h" -#include "lazy-instance.h" -#include "mark-compact.h" -#include "safepoint-table.h" -#include "scopeinfo.h" -#include "string-stream.h" -#include "vm-state-inl.h" +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/v8.h" + +#include "src/ast.h" +#include "src/deoptimizer.h" +#include "src/frames-inl.h" +#include "src/full-codegen.h" +#include "src/mark-compact.h" +#include "src/safepoint-table.h" +#include "src/scopeinfo.h" +#include "src/string-stream.h" +#include "src/vm-state-inl.h" namespace v8 { namespace internal { @@ -473,7 +449,7 @@ StackFrame::Type StackFrame::GetCallerState(State* state) const { Address StackFrame::UnpaddedFP() const { -#if V8_TARGET_ARCH_IA32 +#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 if (!is_optimized()) return fp(); int32_t alignment_state = Memory::int32_at( fp() + JavaScriptFrameConstants::kDynamicAlignmentStateOffset); @@ -531,6 +507,10 @@ void ExitFrame::ComputeCallerState(State* state) const { state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); state->pc_address = ResolveReturnAddressLocation( reinterpret_cast<Address*>(fp() + ExitFrameConstants::kCallerPCOffset)); + if (FLAG_enable_ool_constant_pool) { + state->constant_pool_address = reinterpret_cast<Address*>( + fp() + ExitFrameConstants::kConstantPoolOffset); + } } @@ -544,6 +524,9 @@ void ExitFrame::Iterate(ObjectVisitor* v) const { // the calling frame. IteratePc(v, pc_address(), LookupCode()); v->VisitPointer(&code_slot()); + if (FLAG_enable_ool_constant_pool) { + v->VisitPointer(&constant_pool_slot()); + } } @@ -571,6 +554,8 @@ void ExitFrame::FillState(Address fp, Address sp, State* state) { state->fp = fp; state->pc_address = ResolveReturnAddressLocation( reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); + state->constant_pool_address = + reinterpret_cast<Address*>(fp + ExitFrameConstants::kConstantPoolOffset); } @@ -607,6 +592,8 @@ void StandardFrame::ComputeCallerState(State* state) const { state->fp = caller_fp(); state->pc_address = ResolveReturnAddressLocation( reinterpret_cast<Address*>(ComputePCAddress(fp()))); + state->constant_pool_address = + reinterpret_cast<Address*>(ComputeConstantPoolAddress(fp())); } @@ -652,7 +639,7 @@ void StandardFrame::IterateCompiledFrame(ObjectVisitor* v) const { // Skip saved double registers. if (safepoint_entry.has_doubles()) { // Number of doubles not known at snapshot time. - ASSERT(!Serializer::enabled()); + ASSERT(!isolate()->serializer_enabled()); parameters_base += DoubleRegister::NumAllocatableRegisters() * kDoubleSize / kPointerSize; } @@ -795,7 +782,6 @@ void JavaScriptFrame::PrintTop(Isolate* isolate, bool print_args, bool print_line_number) { // constructor calls - HandleScope scope(isolate); DisallowHeapAllocation no_allocation; JavaScriptFrameIterator it(isolate); while (!it.done()) { @@ -816,15 +802,15 @@ void JavaScriptFrame::PrintTop(Isolate* isolate, 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; + Script* script = Script::cast(maybe_script); + int line = script->GetLineNumber(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); + PrintF(file, " at %s:%d", c_script_name.get(), line); } else { PrintF(file, " at <unknown>:%d", line); } @@ -980,13 +966,10 @@ void OptimizedFrame::Summarize(List<FrameSummary>* frames) { it.Next(); // Skip height. // The translation commands are ordered and the receiver is always - // at the first position. Since we are always at a call when we need - // to construct a stack trace, the receiver is always in a stack slot. + // at the first position. + // If we are at a call, the receiver is always in a stack slot. + // Otherwise we are not guaranteed to get the receiver value. opcode = static_cast<Translation::Opcode>(it.Next()); - ASSERT(opcode == Translation::STACK_SLOT || - opcode == Translation::LITERAL || - opcode == Translation::CAPTURED_OBJECT || - opcode == Translation::DUPLICATED_OBJECT); int index = it.Next(); // Get the correct receiver in the optimized frame. @@ -1010,6 +993,7 @@ void OptimizedFrame::Summarize(List<FrameSummary>* frames) { : this->GetParameter(parameter_index); } } else { + // The receiver is not in a stack slot nor in a literal. We give up. // TODO(3029): Materializing a captured object (or duplicated // object) is hard, we return undefined for now. This breaks the // produced stack trace, as constructor frames aren't marked as @@ -1160,7 +1144,7 @@ void StackFrame::PrintIndex(StringStream* accumulator, void JavaScriptFrame::Print(StringStream* accumulator, PrintMode mode, int index) const { - HandleScope scope(isolate()); + DisallowHeapAllocation no_gc; Object* receiver = this->receiver(); JSFunction* function = this->function(); @@ -1174,13 +1158,11 @@ void JavaScriptFrame::Print(StringStream* accumulator, // doesn't contain scope info, scope_info will return 0 for the number of // parameters, stack local variables, context local variables, stack slots, // or context slots. - Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); - - Handle<SharedFunctionInfo> shared(function->shared()); - scope_info = Handle<ScopeInfo>(shared->scope_info()); + SharedFunctionInfo* shared = function->shared(); + ScopeInfo* scope_info = shared->scope_info(); Object* script_obj = shared->script(); if (script_obj->IsScript()) { - Handle<Script> script(Script::cast(script_obj)); + Script* script = Script::cast(script_obj); accumulator->Add(" ["); accumulator->PrintName(script->name()); @@ -1188,11 +1170,11 @@ void JavaScriptFrame::Print(StringStream* accumulator, 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; + int line = script->GetLineNumber(source_pos) + 1; accumulator->Add(":%d", line); } else { int function_start_pos = shared->start_position(); - int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; + int line = script->GetLineNumber(function_start_pos) + 1; accumulator->Add(":~%d", line); } @@ -1252,6 +1234,10 @@ void JavaScriptFrame::Print(StringStream* accumulator, if (this->context() != NULL && this->context()->IsContext()) { context = Context::cast(this->context()); } + while (context->IsWithContext()) { + context = context->previous(); + ASSERT(context != NULL); + } // Print heap-allocated local variables. if (heap_locals_count > 0) { @@ -1262,8 +1248,9 @@ void JavaScriptFrame::Print(StringStream* accumulator, accumulator->PrintName(scope_info->ContextLocalName(i)); accumulator->Add(" = "); if (context != NULL) { - if (i < context->length()) { - accumulator->Add("%o", context->get(Context::MIN_CONTEXT_SLOTS + i)); + int index = Context::MIN_CONTEXT_SLOTS + i; + if (index < context->length()) { + accumulator->Add("%o", context->get(index)); } else { accumulator->Add( "// warning: missing context slot - inconsistent frame?"); @@ -1343,7 +1330,7 @@ void EntryFrame::Iterate(ObjectVisitor* v) const { void StandardFrame::IterateExpressions(ObjectVisitor* v) const { - const int offset = StandardFrameConstants::kContextOffset; + const int offset = StandardFrameConstants::kLastObjectOffset; Object** base = &Memory::Object_at(sp()); Object** limit = &Memory::Object_at(fp() + offset) + 1; for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) { @@ -1381,7 +1368,7 @@ void StubFailureTrampolineFrame::Iterate(ObjectVisitor* v) const { kFirstRegisterParameterFrameOffset); v->VisitPointers(base, limit); base = &Memory::Object_at(fp() + StandardFrameConstants::kMarkerOffset); - const int offset = StandardFrameConstants::kContextOffset; + const int offset = StandardFrameConstants::kLastObjectOffset; limit = &Memory::Object_at(fp() + offset) + 1; v->VisitPointers(base, limit); IteratePc(v, pc_address(), LookupCode()); @@ -1395,19 +1382,14 @@ Address StubFailureTrampolineFrame::GetCallerStackPointer() const { Code* StubFailureTrampolineFrame::unchecked_code() const { Code* trampoline; - StubFailureTrampolineStub(NOT_JS_FUNCTION_STUB_MODE). - FindCodeInCache(&trampoline, isolate()); - if (trampoline->contains(pc())) { - return trampoline; - } - - StubFailureTrampolineStub(JS_FUNCTION_STUB_MODE). - FindCodeInCache(&trampoline, isolate()); + StubFailureTrampolineStub(isolate(), NOT_JS_FUNCTION_STUB_MODE). + FindCodeInCache(&trampoline); if (trampoline->contains(pc())) { return trampoline; } - StubFailureTailCallTrampolineStub().FindCodeInCache(&trampoline, isolate()); + StubFailureTrampolineStub(isolate(), JS_FUNCTION_STUB_MODE). + FindCodeInCache(&trampoline); if (trampoline->contains(pc())) { return trampoline; } |