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

Side by Side Diff: src/objects-inl.h

Issue 11566027: Object.oberve: assertions to narrow down flaky crashes with array length mutation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 void JSObject::initialize_elements() { 1410 void JSObject::initialize_elements() {
1411 ASSERT(map()->has_fast_smi_or_object_elements() || 1411 ASSERT(map()->has_fast_smi_or_object_elements() ||
1412 map()->has_fast_double_elements()); 1412 map()->has_fast_double_elements());
1413 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); 1413 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
1414 WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array()); 1414 WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array());
1415 } 1415 }
1416 1416
1417 1417
1418 MaybeObject* JSObject::ResetElements() { 1418 MaybeObject* JSObject::ResetElements() {
1419 Object* obj; 1419 Object* obj;
1420 Map* old_map = map();
1421 bool is_observed = old_map->is_observed();
1422 // Temporarily disable observation bit, so that invariant forbidding
1423 // observation on fast elements isn't violated when transitioning below.
1424 // If it was set, we first normalize and then reenable below.
1425 if (is_observed) old_map->set_is_observed(false);
Michael Starzinger 2012/12/14 11:47:51 This modifies the old_map before a new one is allo
rossberg 2012/12/14 12:18:14 Indeed. This was way too ugly anyway. Removed use
1420 ElementsKind elements_kind = GetInitialFastElementsKind(); 1426 ElementsKind elements_kind = GetInitialFastElementsKind();
1421 if (!FLAG_smi_only_arrays) { 1427 if (!FLAG_smi_only_arrays) {
1422 elements_kind = FastSmiToObjectElementsKind(elements_kind); 1428 elements_kind = FastSmiToObjectElementsKind(elements_kind);
1423 } 1429 }
1424 MaybeObject* maybe_obj = GetElementsTransitionMap(GetIsolate(), 1430 MaybeObject* maybe_obj = GetElementsTransitionMap(GetIsolate(),
1425 elements_kind); 1431 elements_kind);
1426 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1432 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1427 set_map(Map::cast(obj)); 1433 set_map(Map::cast(obj));
1428 initialize_elements(); 1434 initialize_elements();
1429 if (FLAG_harmony_observation && map()->is_observed()) { 1435 if (is_observed) {
1430 // Maintain invariant that observed elements are always in dictionary mode. 1436 // Maintain invariant that observed elements are always in dictionary mode.
1431 // For this to work on arrays, we have to make sure to reset length first. 1437 // For this to work on arrays, we have to make sure to reset length first.
1432 if (IsJSArray()) JSArray::cast(this)->set_length(Smi::FromInt(0)); 1438 if (IsJSArray()) JSArray::cast(this)->set_length(Smi::FromInt(0));
1433 maybe_obj = NormalizeElements(); 1439 maybe_obj = NormalizeElements();
1434 if (maybe_obj->IsFailure()) return maybe_obj; 1440 if (maybe_obj->IsFailure()) return maybe_obj;
1441 old_map->set_is_observed(true);
1442 map()->set_is_observed(true);
1435 } 1443 }
1436 return this; 1444 return this;
1437 } 1445 }
1438 1446
1439 1447
1440 MaybeObject* JSObject::AddFastPropertyUsingMap(Map* map) { 1448 MaybeObject* JSObject::AddFastPropertyUsingMap(Map* map) {
1441 ASSERT(this->map()->NumberOfOwnDescriptors() + 1 == 1449 ASSERT(this->map()->NumberOfOwnDescriptors() + 1 ==
1442 map->NumberOfOwnDescriptors()); 1450 map->NumberOfOwnDescriptors());
1443 if (this->map()->unused_property_fields() == 0) { 1451 if (this->map()->unused_property_fields() == 0) {
1444 int new_size = properties()->length() + map->unused_property_fields() + 1; 1452 int new_size = properties()->length() + map->unused_property_fields() + 1;
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 set_bit_field3(OwnsDescriptors::update(bit_field3(), is_shared)); 3363 set_bit_field3(OwnsDescriptors::update(bit_field3(), is_shared));
3356 } 3364 }
3357 3365
3358 3366
3359 bool Map::owns_descriptors() { 3367 bool Map::owns_descriptors() {
3360 return OwnsDescriptors::decode(bit_field3()); 3368 return OwnsDescriptors::decode(bit_field3());
3361 } 3369 }
3362 3370
3363 3371
3364 void Map::set_is_observed(bool is_observed) { 3372 void Map::set_is_observed(bool is_observed) {
3373 ASSERT(instance_type() < FIRST_JS_OBJECT_TYPE ||
3374 instance_type() > LAST_JS_OBJECT_TYPE ||
3375 has_slow_elements_kind() || has_external_array_elements());
3365 set_bit_field3(IsObserved::update(bit_field3(), is_observed)); 3376 set_bit_field3(IsObserved::update(bit_field3(), is_observed));
3366 } 3377 }
3367 3378
3368 3379
3369 bool Map::is_observed() { 3380 bool Map::is_observed() {
3370 return IsObserved::decode(bit_field3()); 3381 return IsObserved::decode(bit_field3());
3371 } 3382 }
3372 3383
3373 3384
3374 void Code::set_flags(Code::Flags flags) { 3385 void Code::set_flags(Code::Flags flags) {
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after
5745 #undef WRITE_UINT32_FIELD 5756 #undef WRITE_UINT32_FIELD
5746 #undef READ_SHORT_FIELD 5757 #undef READ_SHORT_FIELD
5747 #undef WRITE_SHORT_FIELD 5758 #undef WRITE_SHORT_FIELD
5748 #undef READ_BYTE_FIELD 5759 #undef READ_BYTE_FIELD
5749 #undef WRITE_BYTE_FIELD 5760 #undef WRITE_BYTE_FIELD
5750 5761
5751 5762
5752 } } // namespace v8::internal 5763 } } // namespace v8::internal
5753 5764
5754 #endif // V8_OBJECTS_INL_H_ 5765 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698