OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // NOTE: Argument 0 is the receiver. The first 'real' argument is | 80 // NOTE: Argument 0 is the receiver. The first 'real' argument is |
81 // argument 1 - BUILTIN_ARG(1). | 81 // argument 1 - BUILTIN_ARG(1). |
82 #define BUILTIN_ARG(n) (__builtin_arg__(n, __argc__, __argv__)) | 82 #define BUILTIN_ARG(n) (__builtin_arg__(n, __argc__, __argv__)) |
83 | 83 |
84 | 84 |
85 #define BUILTIN_END \ | 85 #define BUILTIN_END \ |
86 return Heap::undefined_value(); \ | 86 return Heap::undefined_value(); \ |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 // TODO(1238487): Get rid of this function that determines if the | |
91 // builtin is called as a constructor. This may be a somewhat slow | |
92 // operation due to the stack frame iteration. | |
93 static inline bool CalledAsConstructor() { | 90 static inline bool CalledAsConstructor() { |
| 91 #ifdef DEBUG |
| 92 // Calculate the result using a full stack frame iterator and check |
| 93 // that the state of the stack is as we assume it to be in the |
| 94 // code below. |
94 StackFrameIterator it; | 95 StackFrameIterator it; |
95 ASSERT(it.frame()->is_exit()); | 96 ASSERT(it.frame()->is_exit()); |
96 it.Advance(); | 97 it.Advance(); |
97 StackFrame* frame = it.frame(); | 98 StackFrame* frame = it.frame(); |
98 return frame->is_construct(); | 99 bool reference_result = frame->is_construct(); |
| 100 #endif |
| 101 Address fp = Top::c_entry_fp(Top::GetCurrentThread()); |
| 102 // Because we know fp points to an exit frame we can use the relevant |
| 103 // part of ExitFrame::ComputeCallerState directly. |
| 104 const int kCallerOffset = ExitFrameConstants::kCallerFPOffset; |
| 105 Address caller_fp = Memory::Address_at(fp + kCallerOffset); |
| 106 // This inlines the part of StackFrame::ComputeType that grabs the |
| 107 // type of the current frame. Note that StackFrame::ComputeType |
| 108 // has been specialized for each architecture so if any one of them |
| 109 // changes this code has to be changed as well. |
| 110 const int kMarkerOffset = StandardFrameConstants::kMarkerOffset; |
| 111 const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); |
| 112 Object* marker = Memory::Object_at(caller_fp + kMarkerOffset); |
| 113 bool result = (marker == kConstructMarker); |
| 114 ASSERT_EQ(result, reference_result); |
| 115 return result; |
99 } | 116 } |
100 | 117 |
101 | |
102 // ---------------------------------------------------------------------------- | 118 // ---------------------------------------------------------------------------- |
103 | 119 |
104 | 120 |
105 Handle<Code> Builtins::GetCode(JavaScript id, bool* resolved) { | 121 Handle<Code> Builtins::GetCode(JavaScript id, bool* resolved) { |
106 Code* code = Builtins::builtin(Builtins::Illegal); | 122 Code* code = Builtins::builtin(Builtins::Illegal); |
107 *resolved = false; | 123 *resolved = false; |
108 | 124 |
109 if (Top::context() != NULL) { | 125 if (Top::context() != NULL) { |
110 Object* object = Top::builtins()->javascript_builtin(id); | 126 Object* object = Top::builtins()->javascript_builtin(id); |
111 if (object->IsJSFunction()) { | 127 if (object->IsJSFunction()) { |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 if (entry->contains(pc)) { | 775 if (entry->contains(pc)) { |
760 return names_[i]; | 776 return names_[i]; |
761 } | 777 } |
762 } | 778 } |
763 } | 779 } |
764 return NULL; | 780 return NULL; |
765 } | 781 } |
766 | 782 |
767 | 783 |
768 } } // namespace v8::internal | 784 } } // namespace v8::internal |
OLD | NEW |