blob: 0fce3cdd955d08597e53adbebc2d0aa169f91bc5 [file] [log] [blame]
Andrei Popescu31002712010-02-23 13:46:05 +00001// Copyright 2010 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29#include "v8.h"
30
Leon Clarkef7060e22010-06-03 12:02:55 +010031#if defined(V8_TARGET_ARCH_MIPS)
32
Andrei Popescu31002712010-02-23 13:46:05 +000033#include "frames-inl.h"
34#include "mips/assembler-mips-inl.h"
35
36namespace v8 {
37namespace internal {
38
39
40StackFrame::Type StackFrame::ComputeType(State* state) {
41 ASSERT(state->fp != NULL);
42 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) {
43 return ARGUMENTS_ADAPTOR;
44 }
45 // The marker and function offsets overlap. If the marker isn't a
46 // smi then the frame is a JavaScript frame -- and the marker is
47 // really the function.
48 const int offset = StandardFrameConstants::kMarkerOffset;
49 Object* marker = Memory::Object_at(state->fp + offset);
50 if (!marker->IsSmi()) return JAVA_SCRIPT;
51 return static_cast<StackFrame::Type>(Smi::cast(marker)->value());
52}
53
54
55StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) {
56 if (fp == 0) return NONE;
57 // Compute frame type and stack pointer.
58 Address sp = fp + ExitFrameConstants::kSPDisplacement;
59 const int offset = ExitFrameConstants::kCodeOffset;
60 Object* code = Memory::Object_at(fp + offset);
61 bool is_debug_exit = code->IsSmi();
62 if (is_debug_exit) {
63 sp -= kNumJSCallerSaved * kPointerSize;
64 }
65 // Fill in the state.
66 state->sp = sp;
67 state->fp = fp;
68 state->pc_address = reinterpret_cast<Address*>(sp - 1 * kPointerSize);
69 return EXIT;
70}
71
72
73void ExitFrame::Iterate(ObjectVisitor* v) const {
74 // Do nothing
75}
76
77
78int JavaScriptFrame::GetProvidedParametersCount() const {
79 return ComputeParametersCount();
80}
81
82
83Address JavaScriptFrame::GetCallerStackPointer() const {
84 UNIMPLEMENTED_MIPS();
85 return static_cast<Address>(NULL); // UNIMPLEMENTED RETURN
86}
87
88
89Address ArgumentsAdaptorFrame::GetCallerStackPointer() const {
90 UNIMPLEMENTED_MIPS();
91 return static_cast<Address>(NULL); // UNIMPLEMENTED RETURN
92}
93
94
95Address InternalFrame::GetCallerStackPointer() const {
Steve Block6ded16b2010-05-10 14:33:55 +010096 return fp() + StandardFrameConstants::kCallerSPOffset;
Andrei Popescu31002712010-02-23 13:46:05 +000097}
98
99
100} } // namespace v8::internal
101
Leon Clarkef7060e22010-06-03 12:02:55 +0100102#endif // V8_TARGET_ARCH_MIPS