OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/messages.h" | 5 #include "src/messages.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/execution.h" | 8 #include "src/execution.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/keys.h" | 10 #include "src/keys.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 fun_ = Handle<JSFunction>::cast(maybe_function); | 175 fun_ = Handle<JSFunction>::cast(maybe_function); |
176 receiver_ = JSObject::GetDataProperty( | 176 receiver_ = JSObject::GetDataProperty( |
177 call_site_obj, isolate->factory()->call_site_receiver_symbol()); | 177 call_site_obj, isolate->factory()->call_site_receiver_symbol()); |
178 } else { | 178 } else { |
179 Handle<Object> maybe_wasm_func_index = JSObject::GetDataProperty( | 179 Handle<Object> maybe_wasm_func_index = JSObject::GetDataProperty( |
180 call_site_obj, isolate->factory()->call_site_wasm_func_index_symbol()); | 180 call_site_obj, isolate->factory()->call_site_wasm_func_index_symbol()); |
181 if (!maybe_wasm_func_index->IsSmi()) { | 181 if (!maybe_wasm_func_index->IsSmi()) { |
182 // invalid: neither javascript nor wasm | 182 // invalid: neither javascript nor wasm |
183 return; | 183 return; |
184 } | 184 } |
| 185 Handle<Object> maybe_wasm_obj = JSObject::GetDataProperty( |
| 186 call_site_obj, isolate->factory()->call_site_wasm_obj_symbol()); |
| 187 if (!maybe_wasm_obj->IsJSObject()) { |
| 188 // invalid: neither javascript nor wasm |
| 189 return; |
| 190 } |
185 // wasm | 191 // wasm |
186 wasm_obj_ = Handle<JSObject>::cast(JSObject::GetDataProperty( | 192 wasm_obj_ = Handle<JSObject>::cast(maybe_wasm_obj); |
187 call_site_obj, isolate->factory()->call_site_wasm_obj_symbol())); | |
188 wasm_func_index_ = Smi::cast(*maybe_wasm_func_index)->value(); | 193 wasm_func_index_ = Smi::cast(*maybe_wasm_func_index)->value(); |
189 DCHECK(static_cast<int>(wasm_func_index_) >= 0); | 194 DCHECK(static_cast<int>(wasm_func_index_) >= 0); |
190 } | 195 } |
191 | 196 |
192 CHECK(JSObject::GetDataProperty( | 197 CHECK(JSObject::GetDataProperty( |
193 call_site_obj, isolate->factory()->call_site_position_symbol()) | 198 call_site_obj, isolate->factory()->call_site_position_symbol()) |
194 ->ToInt32(&pos_)); | 199 ->ToInt32(&pos_)); |
195 } | 200 } |
196 | 201 |
197 | 202 |
198 Handle<Object> CallSite::GetFileName() { | 203 Handle<Object> CallSite::GetFileName() { |
199 if (!IsJavaScript()) return isolate_->factory()->null_value(); | 204 if (!IsJavaScript()) return isolate_->factory()->null_value(); |
200 Object* script = fun_->shared()->script(); | 205 Object* script = fun_->shared()->script(); |
201 if (!script->IsScript()) return isolate_->factory()->null_value(); | 206 if (!script->IsScript()) return isolate_->factory()->null_value(); |
202 return Handle<Object>(Script::cast(script)->name(), isolate_); | 207 return Handle<Object>(Script::cast(script)->name(), isolate_); |
203 } | 208 } |
204 | 209 |
205 | 210 |
206 Handle<Object> CallSite::GetFunctionName() { | 211 Handle<Object> CallSite::GetFunctionName() { |
207 if (IsWasm()) { | 212 if (IsWasm()) { |
208 MaybeHandle<String> name; | 213 MaybeHandle<String> name = wasm::GetWasmFunctionName( |
209 if (!wasm_obj_->IsUndefined()) { | 214 Handle<JSObject>::cast(wasm_obj_), wasm_func_index_); |
210 name = wasm::GetWasmFunctionName(Handle<JSObject>::cast(wasm_obj_), | |
211 wasm_func_index_); | |
212 } | |
213 if (name.is_null()) return isolate_->factory()->null_value(); | 215 if (name.is_null()) return isolate_->factory()->null_value(); |
214 return name.ToHandleChecked(); | 216 return name.ToHandleChecked(); |
215 } | 217 } |
216 Handle<String> result = JSFunction::GetName(fun_); | 218 Handle<String> result = JSFunction::GetName(fun_); |
217 if (result->length() != 0) return result; | 219 if (result->length() != 0) return result; |
218 | 220 |
219 Handle<Object> script(fun_->shared()->script(), isolate_); | 221 Handle<Object> script(fun_->shared()->script(), isolate_); |
220 if (script->IsScript() && | 222 if (script->IsScript() && |
221 Handle<Script>::cast(script)->compilation_type() == | 223 Handle<Script>::cast(script)->compilation_type() == |
222 Script::COMPILATION_TYPE_EVAL) { | 224 Script::COMPILATION_TYPE_EVAL) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 builder.AppendCharacter(*c); | 448 builder.AppendCharacter(*c); |
447 } | 449 } |
448 } | 450 } |
449 | 451 |
450 return builder.Finish(); | 452 return builder.Finish(); |
451 } | 453 } |
452 | 454 |
453 | 455 |
454 } // namespace internal | 456 } // namespace internal |
455 } // namespace v8 | 457 } // namespace v8 |
OLD | NEW |