Chromium Code Reviews

Side by Side Diff: src/runtime/runtime.cc

Issue 1752133004: [proxies] throw TypeError in [[Call]] if is_callable Map bit is unset (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime.h" 5 #include "src/runtime/runtime.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/ast/prettyprinter.h"
8 #include "src/contexts.h" 9 #include "src/contexts.h"
10 #include "src/frames-inl.h"
9 #include "src/handles-inl.h" 11 #include "src/handles-inl.h"
10 #include "src/heap/heap.h" 12 #include "src/heap/heap.h"
13 #include "src/isolate-inl.h"
11 #include "src/isolate.h" 14 #include "src/isolate.h"
15 #include "src/parsing/parser.h"
12 #include "src/runtime/runtime-utils.h" 16 #include "src/runtime/runtime-utils.h"
13 17
14 namespace v8 { 18 namespace v8 {
15 namespace internal { 19 namespace internal {
16 20
17 // Header of runtime functions. 21 // Header of runtime functions.
18 #define F(name, number_of_args, result_size) \ 22 #define F(name, number_of_args, result_size) \
19 Object* Runtime_##name(int args_length, Object** args_object, \ 23 Object* Runtime_##name(int args_length, Object** args_object, \
20 Isolate* isolate); 24 Isolate* isolate);
21 FOR_EACH_INTRINSIC_RETURN_OBJECT(F) 25 FOR_EACH_INTRINSIC_RETURN_OBJECT(F)
(...skipping 96 matching lines...)
118 isolate->runtime_state()->set_redirected_intrinsic_functions( 122 isolate->runtime_state()->set_redirected_intrinsic_functions(
119 redirected_functions); 123 redirected_functions);
120 } 124 }
121 125
122 return isolate->runtime_state()->redirected_intrinsic_functions(); 126 return isolate->runtime_state()->redirected_intrinsic_functions();
123 } else { 127 } else {
124 return kIntrinsicFunctions; 128 return kIntrinsicFunctions;
125 } 129 }
126 } 130 }
127 131
132 bool Runtime::ComputeLocation(Isolate* isolate, MessageLocation* target) {
133 JavaScriptFrameIterator it(isolate);
134 if (!it.done()) {
135 JavaScriptFrame* frame = it.frame();
136 JSFunction* fun = frame->function();
137 Object* script = fun->shared()->script();
138 if (script->IsScript() &&
139 !(Script::cast(script)->source()->IsUndefined())) {
140 Handle<Script> casted_script(Script::cast(script));
141 // Compute the location from the function and the relocation info of the
142 // baseline code. For optimized code this will use the deoptimization
143 // information to get canonical location information.
144 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
145 it.frame()->Summarize(&frames);
146 FrameSummary& summary = frames.last();
147 int pos = summary.abstract_code()->SourcePosition(summary.code_offset());
148 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
149 return true;
150 }
151 }
152 return false;
153 }
154
155 Handle<String> Runtime::RenderCallSite(Isolate* isolate,
156 Handle<Object> object) {
157 MessageLocation location;
158 if (ComputeLocation(isolate, &location)) {
159 Zone zone;
160 base::SmartPointer<ParseInfo> info(
161 location.function()->shared()->is_function()
162 ? new ParseInfo(&zone, location.function())
163 : new ParseInfo(&zone, location.script()));
164 if (Parser::ParseStatic(info.get())) {
165 CallPrinter printer(isolate, location.function()->shared()->IsBuiltin());
166 const char* string = printer.Print(info->literal(), location.start_pos());
167 if (strlen(string) > 0) {
168 return isolate->factory()->NewStringFromAsciiChecked(string);
169 }
170 } else {
171 isolate->clear_pending_exception();
172 }
173 }
174 return Object::TypeOf(isolate, object);
175 }
128 176
129 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) { 177 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) {
130 return os << Runtime::FunctionForId(id)->name; 178 return os << Runtime::FunctionForId(id)->name;
131 } 179 }
132 180
133 181
134 } // namespace internal 182 } // namespace internal
135 } // namespace v8 183 } // namespace v8
OLDNEW

Powered by Google App Engine