| 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 } | |
| 191 // wasm | 185 // wasm |
| 192 wasm_obj_ = Handle<JSObject>::cast(maybe_wasm_obj); | 186 wasm_obj_ = Handle<JSObject>::cast(JSObject::GetDataProperty( |
| 187 call_site_obj, isolate->factory()->call_site_wasm_obj_symbol())); |
| 193 wasm_func_index_ = Smi::cast(*maybe_wasm_func_index)->value(); | 188 wasm_func_index_ = Smi::cast(*maybe_wasm_func_index)->value(); |
| 194 DCHECK(static_cast<int>(wasm_func_index_) >= 0); | 189 DCHECK(static_cast<int>(wasm_func_index_) >= 0); |
| 195 } | 190 } |
| 196 | 191 |
| 197 CHECK(JSObject::GetDataProperty( | 192 CHECK(JSObject::GetDataProperty( |
| 198 call_site_obj, isolate->factory()->call_site_position_symbol()) | 193 call_site_obj, isolate->factory()->call_site_position_symbol()) |
| 199 ->ToInt32(&pos_)); | 194 ->ToInt32(&pos_)); |
| 200 } | 195 } |
| 201 | 196 |
| 202 | 197 |
| 203 Handle<Object> CallSite::GetFileName() { | 198 Handle<Object> CallSite::GetFileName() { |
| 204 if (!IsJavaScript()) return isolate_->factory()->null_value(); | 199 if (!IsJavaScript()) return isolate_->factory()->null_value(); |
| 205 Object* script = fun_->shared()->script(); | 200 Object* script = fun_->shared()->script(); |
| 206 if (!script->IsScript()) return isolate_->factory()->null_value(); | 201 if (!script->IsScript()) return isolate_->factory()->null_value(); |
| 207 return Handle<Object>(Script::cast(script)->name(), isolate_); | 202 return Handle<Object>(Script::cast(script)->name(), isolate_); |
| 208 } | 203 } |
| 209 | 204 |
| 210 | 205 |
| 211 Handle<Object> CallSite::GetFunctionName() { | 206 Handle<Object> CallSite::GetFunctionName() { |
| 212 if (IsWasm()) { | 207 if (IsWasm()) { |
| 213 MaybeHandle<String> name = wasm::GetWasmFunctionName( | 208 MaybeHandle<String> name = |
| 214 Handle<JSObject>::cast(wasm_obj_), wasm_func_index_); | 209 wasm::GetWasmFunctionName(wasm_obj_, wasm_func_index_); |
| 215 if (name.is_null()) return isolate_->factory()->null_value(); | 210 if (name.is_null()) return isolate_->factory()->null_value(); |
| 216 return name.ToHandleChecked(); | 211 return name.ToHandleChecked(); |
| 217 } | 212 } |
| 218 Handle<String> result = JSFunction::GetName(fun_); | 213 Handle<String> result = JSFunction::GetName(fun_); |
| 219 if (result->length() != 0) return result; | 214 if (result->length() != 0) return result; |
| 220 | 215 |
| 221 Handle<Object> script(fun_->shared()->script(), isolate_); | 216 Handle<Object> script(fun_->shared()->script(), isolate_); |
| 222 if (script->IsScript() && | 217 if (script->IsScript() && |
| 223 Handle<Script>::cast(script)->compilation_type() == | 218 Handle<Script>::cast(script)->compilation_type() == |
| 224 Script::COMPILATION_TYPE_EVAL) { | 219 Script::COMPILATION_TYPE_EVAL) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 builder.AppendCharacter(*c); | 443 builder.AppendCharacter(*c); |
| 449 } | 444 } |
| 450 } | 445 } |
| 451 | 446 |
| 452 return builder.Finish(); | 447 return builder.Finish(); |
| 453 } | 448 } |
| 454 | 449 |
| 455 | 450 |
| 456 } // namespace internal | 451 } // namespace internal |
| 457 } // namespace v8 | 452 } // namespace v8 |
| OLD | NEW |