OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 switch (map()->instance_type()) { | 1866 switch (map()->instance_type()) { |
1867 case JS_ARRAY_TYPE: { | 1867 case JS_ARRAY_TYPE: { |
1868 double length = JSArray::cast(this)->length()->IsUndefined() | 1868 double length = JSArray::cast(this)->length()->IsUndefined() |
1869 ? 0 | 1869 ? 0 |
1870 : JSArray::cast(this)->length()->Number(); | 1870 : JSArray::cast(this)->length()->Number(); |
1871 accumulator->Add("<JS Array[%u]>", static_cast<uint32_t>(length)); | 1871 accumulator->Add("<JS Array[%u]>", static_cast<uint32_t>(length)); |
1872 break; | 1872 break; |
1873 } | 1873 } |
1874 case JS_BOUND_FUNCTION_TYPE: { | 1874 case JS_BOUND_FUNCTION_TYPE: { |
1875 JSBoundFunction* bound_function = JSBoundFunction::cast(this); | 1875 JSBoundFunction* bound_function = JSBoundFunction::cast(this); |
1876 Object* name = bound_function->name(); | |
1877 accumulator->Add("<JS BoundFunction"); | 1876 accumulator->Add("<JS BoundFunction"); |
1878 if (name->IsString()) { | |
1879 String* str = String::cast(name); | |
1880 if (str->length() > 0) { | |
1881 accumulator->Add(" "); | |
1882 accumulator->Put(str); | |
1883 } | |
1884 } | |
1885 accumulator->Add( | 1877 accumulator->Add( |
1886 " (BoundTargetFunction %p)>", | 1878 " (BoundTargetFunction %p)>", |
1887 reinterpret_cast<void*>(bound_function->bound_target_function())); | 1879 reinterpret_cast<void*>(bound_function->bound_target_function())); |
1888 break; | 1880 break; |
1889 } | 1881 } |
1890 case JS_WEAK_MAP_TYPE: { | 1882 case JS_WEAK_MAP_TYPE: { |
1891 accumulator->Add("<JS WeakMap>"); | 1883 accumulator->Add("<JS WeakMap>"); |
1892 break; | 1884 break; |
1893 } | 1885 } |
1894 case JS_WEAK_SET_TYPE: { | 1886 case JS_WEAK_SET_TYPE: { |
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5100 | 5092 |
5101 | 5093 |
5102 // static | 5094 // static |
5103 MaybeHandle<Context> JSBoundFunction::GetFunctionRealm( | 5095 MaybeHandle<Context> JSBoundFunction::GetFunctionRealm( |
5104 Handle<JSBoundFunction> function) { | 5096 Handle<JSBoundFunction> function) { |
5105 DCHECK(function->map()->is_constructor()); | 5097 DCHECK(function->map()->is_constructor()); |
5106 return JSReceiver::GetFunctionRealm( | 5098 return JSReceiver::GetFunctionRealm( |
5107 handle(function->bound_target_function())); | 5099 handle(function->bound_target_function())); |
5108 } | 5100 } |
5109 | 5101 |
| 5102 // static |
| 5103 MaybeHandle<String> JSBoundFunction::GetName(Isolate* isolate, |
| 5104 Handle<JSBoundFunction> function) { |
| 5105 Handle<String> prefix = isolate->factory()->bound__string(); |
| 5106 if (!function->bound_target_function()->IsJSFunction()) return prefix; |
| 5107 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()), |
| 5108 isolate); |
| 5109 Handle<Object> target_name = JSFunction::GetName(isolate, target); |
| 5110 if (!target_name->IsString()) return prefix; |
| 5111 Factory* factory = isolate->factory(); |
| 5112 return factory->NewConsString(prefix, Handle<String>::cast(target_name)); |
| 5113 } |
| 5114 |
| 5115 // static |
| 5116 Handle<Object> JSFunction::GetName(Isolate* isolate, |
| 5117 Handle<JSFunction> function) { |
| 5118 if (function->shared()->name_should_print_as_anonymous()) { |
| 5119 return isolate->factory()->anonymous_string(); |
| 5120 } |
| 5121 return handle(function->shared()->name(), isolate); |
| 5122 } |
| 5123 |
| 5124 // static |
| 5125 MaybeHandle<Smi> JSFunction::GetLength(Isolate* isolate, |
| 5126 Handle<JSFunction> function) { |
| 5127 int length = 0; |
| 5128 if (function->shared()->is_compiled()) { |
| 5129 length = function->shared()->length(); |
| 5130 } else { |
| 5131 // If the function isn't compiled yet, the length is not computed |
| 5132 // correctly yet. Compile it now and return the right length. |
| 5133 if (Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) { |
| 5134 length = function->shared()->length(); |
| 5135 } |
| 5136 if (isolate->has_pending_exception()) return MaybeHandle<Smi>(); |
| 5137 } |
| 5138 return handle(Smi::FromInt(length), isolate); |
| 5139 } |
5110 | 5140 |
5111 // static | 5141 // static |
5112 Handle<Context> JSFunction::GetFunctionRealm(Handle<JSFunction> function) { | 5142 Handle<Context> JSFunction::GetFunctionRealm(Handle<JSFunction> function) { |
5113 DCHECK(function->map()->is_constructor()); | 5143 DCHECK(function->map()->is_constructor()); |
5114 return handle(function->context()->native_context()); | 5144 return handle(function->context()->native_context()); |
5115 } | 5145 } |
5116 | 5146 |
5117 | 5147 |
5118 // static | 5148 // static |
5119 MaybeHandle<Context> JSObject::GetFunctionRealm(Handle<JSObject> object) { | 5149 MaybeHandle<Context> JSObject::GetFunctionRealm(Handle<JSObject> object) { |
(...skipping 14166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19286 if (cell->value() != *new_value) { | 19316 if (cell->value() != *new_value) { |
19287 cell->set_value(*new_value); | 19317 cell->set_value(*new_value); |
19288 Isolate* isolate = cell->GetIsolate(); | 19318 Isolate* isolate = cell->GetIsolate(); |
19289 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19319 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19290 isolate, DependentCode::kPropertyCellChangedGroup); | 19320 isolate, DependentCode::kPropertyCellChangedGroup); |
19291 } | 19321 } |
19292 } | 19322 } |
19293 | 19323 |
19294 } // namespace internal | 19324 } // namespace internal |
19295 } // namespace v8 | 19325 } // namespace v8 |
OLD | NEW |