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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 Handle<Object> object, | 91 Handle<Object> object, |
92 Handle<Context> native_context) { | 92 Handle<Context> native_context) { |
93 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); | 93 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); |
94 Handle<JSFunction> constructor; | 94 Handle<JSFunction> constructor; |
95 if (object->IsSmi()) { | 95 if (object->IsSmi()) { |
96 constructor = handle(native_context->number_function(), isolate); | 96 constructor = handle(native_context->number_function(), isolate); |
97 } else { | 97 } else { |
98 int constructor_function_index = | 98 int constructor_function_index = |
99 Handle<HeapObject>::cast(object)->map()->GetConstructorFunctionIndex(); | 99 Handle<HeapObject>::cast(object)->map()->GetConstructorFunctionIndex(); |
100 if (constructor_function_index == Map::kNoConstructorFunctionIndex) { | 100 if (constructor_function_index == Map::kNoConstructorFunctionIndex) { |
101 return MaybeHandle<JSReceiver>(); | 101 THROW_NEW_ERROR(isolate, |
| 102 NewTypeError(MessageTemplate::kUndefinedOrNullToObject), |
| 103 JSReceiver); |
102 } | 104 } |
103 constructor = handle( | 105 constructor = handle( |
104 JSFunction::cast(native_context->get(constructor_function_index)), | 106 JSFunction::cast(native_context->get(constructor_function_index)), |
105 isolate); | 107 isolate); |
106 } | 108 } |
107 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); | 109 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); |
108 Handle<JSValue>::cast(result)->set_value(*object); | 110 Handle<JSValue>::cast(result)->set_value(*object); |
109 return result; | 111 return result; |
110 } | 112 } |
111 | 113 |
(...skipping 16434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16546 DCHECK(!storage || storage->length() == counter); | 16548 DCHECK(!storage || storage->length() == counter); |
16547 return counter; | 16549 return counter; |
16548 } | 16550 } |
16549 | 16551 |
16550 | 16552 |
16551 MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate, | 16553 MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate, |
16552 Handle<Object> object) { | 16554 Handle<Object> object) { |
16553 if (object->IsUndefined()) return isolate->factory()->undefined_to_string(); | 16555 if (object->IsUndefined()) return isolate->factory()->undefined_to_string(); |
16554 if (object->IsNull()) return isolate->factory()->null_to_string(); | 16556 if (object->IsNull()) return isolate->factory()->null_to_string(); |
16555 | 16557 |
16556 Handle<JSReceiver> receiver; | 16558 Handle<JSReceiver> receiver = |
16557 CHECK(Object::ToObject(isolate, object).ToHandle(&receiver)); | 16559 Object::ToObject(isolate, object).ToHandleChecked(); |
16558 | 16560 |
16559 Handle<String> tag; | 16561 Handle<String> tag; |
16560 if (FLAG_harmony_tostring) { | 16562 if (FLAG_harmony_tostring) { |
16561 Handle<Object> to_string_tag; | 16563 Handle<Object> to_string_tag; |
16562 ASSIGN_RETURN_ON_EXCEPTION( | 16564 ASSIGN_RETURN_ON_EXCEPTION( |
16563 isolate, to_string_tag, | 16565 isolate, to_string_tag, |
16564 GetProperty(receiver, isolate->factory()->to_string_tag_symbol()), | 16566 GetProperty(receiver, isolate->factory()->to_string_tag_symbol()), |
16565 String); | 16567 String); |
16566 if (to_string_tag->IsString()) { | 16568 if (to_string_tag->IsString()) { |
16567 tag = Handle<String>::cast(to_string_tag); | 16569 tag = Handle<String>::cast(to_string_tag); |
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19665 if (cell->value() != *new_value) { | 19667 if (cell->value() != *new_value) { |
19666 cell->set_value(*new_value); | 19668 cell->set_value(*new_value); |
19667 Isolate* isolate = cell->GetIsolate(); | 19669 Isolate* isolate = cell->GetIsolate(); |
19668 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19670 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19669 isolate, DependentCode::kPropertyCellChangedGroup); | 19671 isolate, DependentCode::kPropertyCellChangedGroup); |
19670 } | 19672 } |
19671 } | 19673 } |
19672 | 19674 |
19673 } // namespace internal | 19675 } // namespace internal |
19674 } // namespace v8 | 19676 } // namespace v8 |
OLD | NEW |