Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: src/objects.cc

Issue 2060213002: Revert of Replace all remaining Oddball checks with new function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 len = 0.0; 225 len = 0.0;
226 } else if (len >= kMaxSafeInteger) { 226 } else if (len >= kMaxSafeInteger) {
227 len = kMaxSafeInteger; 227 len = kMaxSafeInteger;
228 } 228 }
229 return isolate->factory()->NewNumber(len); 229 return isolate->factory()->NewNumber(len);
230 } 230 }
231 231
232 232
233 bool Object::BooleanValue() { 233 bool Object::BooleanValue() {
234 if (IsSmi()) return Smi::cast(this)->value() != 0; 234 if (IsSmi()) return Smi::cast(this)->value() != 0;
235 if (IsBoolean()) return IsTrue();
235 DCHECK(IsHeapObject()); 236 DCHECK(IsHeapObject());
236 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); 237 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
237 if (IsBoolean()) return IsTrue(isolate); 238 if (IsUndefined(isolate) || IsNull()) return false;
238 if (IsUndefined(isolate) || IsNull(isolate)) return false;
239 if (IsUndetectable()) return false; // Undetectable object is false. 239 if (IsUndetectable()) return false; // Undetectable object is false.
240 if (IsString()) return String::cast(this)->length() != 0; 240 if (IsString()) return String::cast(this)->length() != 0;
241 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); 241 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue();
242 return true; 242 return true;
243 } 243 }
244 244
245 245
246 namespace { 246 namespace {
247 247
248 // TODO(bmeurer): Maybe we should introduce a marker interface Number, 248 // TODO(bmeurer): Maybe we should introduce a marker interface Number,
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 687 }
688 688
689 689
690 // static 690 // static
691 MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver, 691 MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver,
692 Handle<Name> name) { 692 Handle<Name> name) {
693 Handle<Object> func; 693 Handle<Object> func;
694 Isolate* isolate = receiver->GetIsolate(); 694 Isolate* isolate = receiver->GetIsolate();
695 ASSIGN_RETURN_ON_EXCEPTION(isolate, func, 695 ASSIGN_RETURN_ON_EXCEPTION(isolate, func,
696 JSReceiver::GetProperty(receiver, name), Object); 696 JSReceiver::GetProperty(receiver, name), Object);
697 if (func->IsNull(isolate) || func->IsUndefined(isolate)) { 697 if (func->IsNull() || func->IsUndefined(isolate)) {
698 return isolate->factory()->undefined_value(); 698 return isolate->factory()->undefined_value();
699 } 699 }
700 if (!func->IsCallable()) { 700 if (!func->IsCallable()) {
701 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction, 701 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kPropertyNotFunction,
702 func, name, receiver), 702 func, name, receiver),
703 Object); 703 Object);
704 } 704 }
705 return func; 705 return func;
706 } 706 }
707 707
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 if (trap->IsUndefined(isolate)) { 1104 if (trap->IsUndefined(isolate)) {
1105 return JSReceiver::GetPrototype(isolate, target); 1105 return JSReceiver::GetPrototype(isolate, target);
1106 } 1106 }
1107 // 7. Let handlerProto be ? Call(trap, handler, «target»). 1107 // 7. Let handlerProto be ? Call(trap, handler, «target»).
1108 Handle<Object> argv[] = {target}; 1108 Handle<Object> argv[] = {target};
1109 Handle<Object> handler_proto; 1109 Handle<Object> handler_proto;
1110 ASSIGN_RETURN_ON_EXCEPTION( 1110 ASSIGN_RETURN_ON_EXCEPTION(
1111 isolate, handler_proto, 1111 isolate, handler_proto,
1112 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object); 1112 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object);
1113 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError. 1113 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError.
1114 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull(isolate))) { 1114 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) {
1115 THROW_NEW_ERROR(isolate, 1115 THROW_NEW_ERROR(isolate,
1116 NewTypeError(MessageTemplate::kProxyGetPrototypeOfInvalid), 1116 NewTypeError(MessageTemplate::kProxyGetPrototypeOfInvalid),
1117 Object); 1117 Object);
1118 } 1118 }
1119 // 9. Let extensibleTarget be ? IsExtensible(target). 1119 // 9. Let extensibleTarget be ? IsExtensible(target).
1120 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target); 1120 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target);
1121 MAYBE_RETURN_NULL(is_extensible); 1121 MAYBE_RETURN_NULL(is_extensible);
1122 // 10. If extensibleTarget is true, return handlerProto. 1122 // 10. If extensibleTarget is true, return handlerProto.
1123 if (is_extensible.FromJust()) return handler_proto; 1123 if (is_extensible.FromJust()) return handler_proto;
1124 // 11. Let targetProto be ? target.[[GetPrototypeOf]](). 1124 // 11. Let targetProto be ? target.[[GetPrototypeOf]]().
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 *constructor == constructor_context->array_function()) { 1686 *constructor == constructor_context->array_function()) {
1687 constructor = isolate->factory()->undefined_value(); 1687 constructor = isolate->factory()->undefined_value();
1688 } 1688 }
1689 } 1689 }
1690 if (constructor->IsJSReceiver()) { 1690 if (constructor->IsJSReceiver()) {
1691 ASSIGN_RETURN_ON_EXCEPTION( 1691 ASSIGN_RETURN_ON_EXCEPTION(
1692 isolate, constructor, 1692 isolate, constructor,
1693 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor), 1693 JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor),
1694 isolate->factory()->species_symbol()), 1694 isolate->factory()->species_symbol()),
1695 Object); 1695 Object);
1696 if (constructor->IsNull(isolate)) { 1696 if (constructor->IsNull()) {
1697 constructor = isolate->factory()->undefined_value(); 1697 constructor = isolate->factory()->undefined_value();
1698 } 1698 }
1699 } 1699 }
1700 } 1700 }
1701 if (constructor->IsUndefined(isolate)) { 1701 if (constructor->IsUndefined(isolate)) {
1702 return default_species; 1702 return default_species;
1703 } else { 1703 } else {
1704 if (!constructor->IsConstructor()) { 1704 if (!constructor->IsConstructor()) {
1705 THROW_NEW_ERROR(isolate, 1705 THROW_NEW_ERROR(isolate,
1706 NewTypeError(MessageTemplate::kSpeciesNotConstructor), 1706 NewTypeError(MessageTemplate::kSpeciesNotConstructor),
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 case CODE_TYPE: { 2319 case CODE_TYPE: {
2320 Code* code = Code::cast(this); 2320 Code* code = Code::cast(this);
2321 os << "<Code: " << Code::Kind2String(code->kind()) << ">"; 2321 os << "<Code: " << Code::Kind2String(code->kind()) << ">";
2322 break; 2322 break;
2323 } 2323 }
2324 case ODDBALL_TYPE: { 2324 case ODDBALL_TYPE: {
2325 if (IsUndefined(isolate)) { 2325 if (IsUndefined(isolate)) {
2326 os << "<undefined>"; 2326 os << "<undefined>";
2327 } else if (IsTheHole(isolate)) { 2327 } else if (IsTheHole(isolate)) {
2328 os << "<the hole>"; 2328 os << "<the hole>";
2329 } else if (IsNull(isolate)) { 2329 } else if (IsNull()) {
2330 os << "<null>"; 2330 os << "<null>";
2331 } else if (IsTrue(isolate)) { 2331 } else if (IsTrue()) {
2332 os << "<true>"; 2332 os << "<true>";
2333 } else if (IsFalse(isolate)) { 2333 } else if (IsFalse()) {
2334 os << "<false>"; 2334 os << "<false>";
2335 } else { 2335 } else {
2336 os << "<Odd Oddball: "; 2336 os << "<Odd Oddball: ";
2337 os << Oddball::cast(this)->to_string()->ToCString().get(); 2337 os << Oddball::cast(this)->to_string()->ToCString().get();
2338 os << ">"; 2338 os << ">";
2339 } 2339 }
2340 break; 2340 break;
2341 } 2341 }
2342 case SYMBOL_TYPE: { 2342 case SYMBOL_TYPE: {
2343 Symbol* symbol = Symbol::cast(this); 2343 Symbol* symbol = Symbol::cast(this);
(...skipping 3668 matching lines...) Expand 10 before | Expand all | Expand 10 after
6012 v8::ToCData<v8::GenericNamedPropertyDeleterCallback>( 6012 v8::ToCData<v8::GenericNamedPropertyDeleterCallback>(
6013 interceptor->deleter()); 6013 interceptor->deleter());
6014 result = args.Call(deleter, name); 6014 result = args.Call(deleter, name);
6015 } 6015 }
6016 6016
6017 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); 6017 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
6018 if (result.is_null()) return Nothing<bool>(); 6018 if (result.is_null()) return Nothing<bool>();
6019 6019
6020 DCHECK(result->IsBoolean()); 6020 DCHECK(result->IsBoolean());
6021 // Rebox CustomArguments::kReturnValueOffset before returning. 6021 // Rebox CustomArguments::kReturnValueOffset before returning.
6022 return Just(result->IsTrue(isolate)); 6022 return Just(result->IsTrue());
6023 } 6023 }
6024 6024
6025 6025
6026 void JSReceiver::DeleteNormalizedProperty(Handle<JSReceiver> object, 6026 void JSReceiver::DeleteNormalizedProperty(Handle<JSReceiver> object,
6027 Handle<Name> name, int entry) { 6027 Handle<Name> name, int entry) {
6028 DCHECK(!object->HasFastProperties()); 6028 DCHECK(!object->HasFastProperties());
6029 Isolate* isolate = object->GetIsolate(); 6029 Isolate* isolate = object->GetIsolate();
6030 6030
6031 if (object->IsJSGlobalObject()) { 6031 if (object->IsJSGlobalObject()) {
6032 // If we have a global object, invalidate the cell and swap in a new one. 6032 // If we have a global object, invalidate the cell and swap in a new one.
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after
8419 it->Next(); 8419 it->Next();
8420 } 8420 }
8421 8421
8422 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); 8422 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
8423 // Ignore accessors on typed arrays. 8423 // Ignore accessors on typed arrays.
8424 if (it->IsElement() && object->HasFixedTypedArrayElements()) { 8424 if (it->IsElement() && object->HasFixedTypedArrayElements()) {
8425 return it->factory()->undefined_value(); 8425 return it->factory()->undefined_value();
8426 } 8426 }
8427 8427
8428 DCHECK(getter->IsCallable() || getter->IsUndefined(isolate) || 8428 DCHECK(getter->IsCallable() || getter->IsUndefined(isolate) ||
8429 getter->IsNull(isolate) || getter->IsFunctionTemplateInfo()); 8429 getter->IsNull() || getter->IsFunctionTemplateInfo());
8430 DCHECK(setter->IsCallable() || setter->IsUndefined(isolate) || 8430 DCHECK(setter->IsCallable() || setter->IsUndefined(isolate) ||
8431 setter->IsNull(isolate) || getter->IsFunctionTemplateInfo()); 8431 setter->IsNull() || getter->IsFunctionTemplateInfo());
8432 it->TransitionToAccessorProperty(getter, setter, attributes); 8432 it->TransitionToAccessorProperty(getter, setter, attributes);
8433 8433
8434 return isolate->factory()->undefined_value(); 8434 return isolate->factory()->undefined_value();
8435 } 8435 }
8436 8436
8437 8437
8438 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, 8438 MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
8439 Handle<AccessorInfo> info) { 8439 Handle<AccessorInfo> info) {
8440 Isolate* isolate = object->GetIsolate(); 8440 Isolate* isolate = object->GetIsolate();
8441 Handle<Name> name(Name::cast(info->name()), isolate); 8441 Handle<Name> name(Name::cast(info->name()), isolate);
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
9242 Handle<Object> getter, 9242 Handle<Object> getter,
9243 Handle<Object> setter, 9243 Handle<Object> setter,
9244 PropertyAttributes attributes) { 9244 PropertyAttributes attributes) {
9245 RuntimeCallTimerScope stats_scope( 9245 RuntimeCallTimerScope stats_scope(
9246 isolate, 9246 isolate,
9247 map->is_prototype_map() 9247 map->is_prototype_map()
9248 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty 9248 ? &RuntimeCallStats::PrototypeMap_TransitionToAccessorProperty
9249 : &RuntimeCallStats::Map_TransitionToAccessorProperty); 9249 : &RuntimeCallStats::Map_TransitionToAccessorProperty);
9250 9250
9251 // At least one of the accessors needs to be a new value. 9251 // At least one of the accessors needs to be a new value.
9252 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate)); 9252 DCHECK(!getter->IsNull() || !setter->IsNull());
9253 DCHECK(name->IsUniqueName()); 9253 DCHECK(name->IsUniqueName());
9254 9254
9255 // Dictionary maps can always have additional data properties. 9255 // Dictionary maps can always have additional data properties.
9256 if (map->is_dictionary_map()) return map; 9256 if (map->is_dictionary_map()) return map;
9257 9257
9258 // Migrate to the newest map before transitioning to the new property. 9258 // Migrate to the newest map before transitioning to the new property.
9259 map = Update(map); 9259 map = Update(map);
9260 9260
9261 PropertyNormalizationMode mode = map->is_prototype_map() 9261 PropertyNormalizationMode mode = map->is_prototype_map()
9262 ? KEEP_INOBJECT_PROPERTIES 9262 ? KEEP_INOBJECT_PROPERTIES
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
9303 9303
9304 Handle<Object> maybe_pair(old_descriptors->GetValue(descriptor), isolate); 9304 Handle<Object> maybe_pair(old_descriptors->GetValue(descriptor), isolate);
9305 if (!maybe_pair->IsAccessorPair()) { 9305 if (!maybe_pair->IsAccessorPair()) {
9306 return Map::Normalize(map, mode, "AccessorsOverwritingNonPair"); 9306 return Map::Normalize(map, mode, "AccessorsOverwritingNonPair");
9307 } 9307 }
9308 9308
9309 Handle<AccessorPair> current_pair = Handle<AccessorPair>::cast(maybe_pair); 9309 Handle<AccessorPair> current_pair = Handle<AccessorPair>::cast(maybe_pair);
9310 if (current_pair->Equals(*getter, *setter)) return map; 9310 if (current_pair->Equals(*getter, *setter)) return map;
9311 9311
9312 bool overwriting_accessor = false; 9312 bool overwriting_accessor = false;
9313 if (!getter->IsNull(isolate) && 9313 if (!getter->IsNull() && !current_pair->get(ACCESSOR_GETTER)->IsNull() &&
9314 !current_pair->get(ACCESSOR_GETTER)->IsNull(isolate) &&
9315 current_pair->get(ACCESSOR_GETTER) != *getter) { 9314 current_pair->get(ACCESSOR_GETTER) != *getter) {
9316 overwriting_accessor = true; 9315 overwriting_accessor = true;
9317 } 9316 }
9318 if (!setter->IsNull(isolate) && 9317 if (!setter->IsNull() && !current_pair->get(ACCESSOR_SETTER)->IsNull() &&
9319 !current_pair->get(ACCESSOR_SETTER)->IsNull(isolate) &&
9320 current_pair->get(ACCESSOR_SETTER) != *setter) { 9318 current_pair->get(ACCESSOR_SETTER) != *setter) {
9321 overwriting_accessor = true; 9319 overwriting_accessor = true;
9322 } 9320 }
9323 if (overwriting_accessor) { 9321 if (overwriting_accessor) {
9324 return Map::Normalize(map, mode, "AccessorsOverwritingAccessors"); 9322 return Map::Normalize(map, mode, "AccessorsOverwritingAccessors");
9325 } 9323 }
9326 9324
9327 pair = AccessorPair::Copy(Handle<AccessorPair>::cast(maybe_pair)); 9325 pair = AccessorPair::Copy(Handle<AccessorPair>::cast(maybe_pair));
9328 } else if (map->NumberOfOwnDescriptors() >= kMaxNumberOfDescriptors || 9326 } else if (map->NumberOfOwnDescriptors() >= kMaxNumberOfDescriptors ||
9329 map->TooManyFastProperties(CERTAINLY_NOT_STORE_FROM_KEYED)) { 9327 map->TooManyFastProperties(CERTAINLY_NOT_STORE_FROM_KEYED)) {
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
10085 10083
10086 Handle<Object> AccessorPair::GetComponent(Handle<AccessorPair> accessor_pair, 10084 Handle<Object> AccessorPair::GetComponent(Handle<AccessorPair> accessor_pair,
10087 AccessorComponent component) { 10085 AccessorComponent component) {
10088 Object* accessor = accessor_pair->get(component); 10086 Object* accessor = accessor_pair->get(component);
10089 if (accessor->IsFunctionTemplateInfo()) { 10087 if (accessor->IsFunctionTemplateInfo()) {
10090 return ApiNatives::InstantiateFunction( 10088 return ApiNatives::InstantiateFunction(
10091 handle(FunctionTemplateInfo::cast(accessor))) 10089 handle(FunctionTemplateInfo::cast(accessor)))
10092 .ToHandleChecked(); 10090 .ToHandleChecked();
10093 } 10091 }
10094 Isolate* isolate = accessor_pair->GetIsolate(); 10092 Isolate* isolate = accessor_pair->GetIsolate();
10095 if (accessor->IsNull(isolate)) { 10093 if (accessor->IsNull()) {
10096 return isolate->factory()->undefined_value(); 10094 return isolate->factory()->undefined_value();
10097 } 10095 }
10098 return handle(accessor, isolate); 10096 return handle(accessor, isolate);
10099 } 10097 }
10100 10098
10101 Handle<DeoptimizationInputData> DeoptimizationInputData::New( 10099 Handle<DeoptimizationInputData> DeoptimizationInputData::New(
10102 Isolate* isolate, int deopt_entry_count, PretenureFlag pretenure) { 10100 Isolate* isolate, int deopt_entry_count, PretenureFlag pretenure) {
10103 return Handle<DeoptimizationInputData>::cast( 10101 return Handle<DeoptimizationInputData>::cast(
10104 isolate->factory()->NewFixedArray(LengthFor(deopt_entry_count), 10102 isolate->factory()->NewFixedArray(LengthFor(deopt_entry_count),
10105 pretenure)); 10103 pretenure));
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
12122 if (maybe_constructor->IsJSFunction()) { 12120 if (maybe_constructor->IsJSFunction()) {
12123 JSFunction* constructor = JSFunction::cast(maybe_constructor); 12121 JSFunction* constructor = JSFunction::cast(maybe_constructor);
12124 Object* data = constructor->shared()->function_data(); 12122 Object* data = constructor->shared()->function_data();
12125 is_hidden = (data->IsFunctionTemplateInfo() && 12123 is_hidden = (data->IsFunctionTemplateInfo() &&
12126 FunctionTemplateInfo::cast(data)->hidden_prototype()) || 12124 FunctionTemplateInfo::cast(data)->hidden_prototype()) ||
12127 prototype->IsJSGlobalObject(); 12125 prototype->IsJSGlobalObject();
12128 } 12126 }
12129 } 12127 }
12130 map->set_has_hidden_prototype(is_hidden); 12128 map->set_has_hidden_prototype(is_hidden);
12131 12129
12132 WriteBarrierMode wb_mode = prototype->IsNull(map->GetIsolate()) 12130 WriteBarrierMode wb_mode =
12133 ? SKIP_WRITE_BARRIER 12131 prototype->IsNull() ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER;
12134 : UPDATE_WRITE_BARRIER;
12135 map->set_prototype(*prototype, wb_mode); 12132 map->set_prototype(*prototype, wb_mode);
12136 } 12133 }
12137 12134
12138 12135
12139 Handle<Object> CacheInitialJSArrayMaps( 12136 Handle<Object> CacheInitialJSArrayMaps(
12140 Handle<Context> native_context, Handle<Map> initial_map) { 12137 Handle<Context> native_context, Handle<Map> initial_map) {
12141 // Replace all of the cached initial array maps in the native context with 12138 // Replace all of the cached initial array maps in the native context with
12142 // the appropriate transitioned elements kind maps. 12139 // the appropriate transitioned elements kind maps.
12143 Handle<Map> current_map = initial_map; 12140 Handle<Map> current_map = initial_map;
12144 ElementsKind kind = current_map->elements_kind(); 12141 ElementsKind kind = current_map->elements_kind();
(...skipping 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after
14798 14795
14799 // ES6: 9.5.2 [[SetPrototypeOf]] (V) 14796 // ES6: 9.5.2 [[SetPrototypeOf]] (V)
14800 // static 14797 // static
14801 Maybe<bool> JSProxy::SetPrototype(Handle<JSProxy> proxy, Handle<Object> value, 14798 Maybe<bool> JSProxy::SetPrototype(Handle<JSProxy> proxy, Handle<Object> value,
14802 bool from_javascript, 14799 bool from_javascript,
14803 ShouldThrow should_throw) { 14800 ShouldThrow should_throw) {
14804 Isolate* isolate = proxy->GetIsolate(); 14801 Isolate* isolate = proxy->GetIsolate();
14805 STACK_CHECK(isolate, Nothing<bool>()); 14802 STACK_CHECK(isolate, Nothing<bool>());
14806 Handle<Name> trap_name = isolate->factory()->setPrototypeOf_string(); 14803 Handle<Name> trap_name = isolate->factory()->setPrototypeOf_string();
14807 // 1. Assert: Either Type(V) is Object or Type(V) is Null. 14804 // 1. Assert: Either Type(V) is Object or Type(V) is Null.
14808 DCHECK(value->IsJSReceiver() || value->IsNull(isolate)); 14805 DCHECK(value->IsJSReceiver() || value->IsNull());
14809 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. 14806 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O.
14810 Handle<Object> handler(proxy->handler(), isolate); 14807 Handle<Object> handler(proxy->handler(), isolate);
14811 // 3. If handler is null, throw a TypeError exception. 14808 // 3. If handler is null, throw a TypeError exception.
14812 // 4. Assert: Type(handler) is Object. 14809 // 4. Assert: Type(handler) is Object.
14813 if (proxy->IsRevoked()) { 14810 if (proxy->IsRevoked()) {
14814 isolate->Throw(*isolate->factory()->NewTypeError( 14811 isolate->Throw(*isolate->factory()->NewTypeError(
14815 MessageTemplate::kProxyRevoked, trap_name)); 14812 MessageTemplate::kProxyRevoked, trap_name));
14816 return Nothing<bool>(); 14813 return Nothing<bool>();
14817 } 14814 }
14818 // 5. Let target be the value of the [[ProxyTarget]] internal slot. 14815 // 5. Let target be the value of the [[ProxyTarget]] internal slot.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
14885 RETURN_FAILURE(isolate, should_throw, 14882 RETURN_FAILURE(isolate, should_throw,
14886 NewTypeError(MessageTemplate::kNoAccess)); 14883 NewTypeError(MessageTemplate::kNoAccess));
14887 } 14884 }
14888 } else { 14885 } else {
14889 DCHECK(!object->IsAccessCheckNeeded()); 14886 DCHECK(!object->IsAccessCheckNeeded());
14890 } 14887 }
14891 14888
14892 Heap* heap = isolate->heap(); 14889 Heap* heap = isolate->heap();
14893 // Silently ignore the change if value is not a JSObject or null. 14890 // Silently ignore the change if value is not a JSObject or null.
14894 // SpiderMonkey behaves this way. 14891 // SpiderMonkey behaves this way.
14895 if (!value->IsJSReceiver() && !value->IsNull(isolate)) return Just(true); 14892 if (!value->IsJSReceiver() && !value->IsNull()) return Just(true);
14896 14893
14897 bool dictionary_elements_in_chain = 14894 bool dictionary_elements_in_chain =
14898 object->map()->DictionaryElementsInPrototypeChainOnly(); 14895 object->map()->DictionaryElementsInPrototypeChainOnly();
14899 14896
14900 bool all_extensible = object->map()->is_extensible(); 14897 bool all_extensible = object->map()->is_extensible();
14901 Handle<JSObject> real_receiver = object; 14898 Handle<JSObject> real_receiver = object;
14902 if (from_javascript) { 14899 if (from_javascript) {
14903 // Find the first object in the chain whose prototype object is not 14900 // Find the first object in the chain whose prototype object is not
14904 // hidden. 14901 // hidden.
14905 PrototypeIterator iter(isolate, real_receiver, kStartAtPrototype, 14902 PrototypeIterator iter(isolate, real_receiver, kStartAtPrototype,
(...skipping 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after
18865 if (cell->value() != *new_value) { 18862 if (cell->value() != *new_value) {
18866 cell->set_value(*new_value); 18863 cell->set_value(*new_value);
18867 Isolate* isolate = cell->GetIsolate(); 18864 Isolate* isolate = cell->GetIsolate();
18868 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18865 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18869 isolate, DependentCode::kPropertyCellChangedGroup); 18866 isolate, DependentCode::kPropertyCellChangedGroup);
18870 } 18867 }
18871 } 18868 }
18872 18869
18873 } // namespace internal 18870 } // namespace internal
18874 } // namespace v8 18871 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698