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

Side by Side Diff: src/builtins.cc

Issue 1905933002: MigrateInstance(target) before Object.assign(target, ...) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | test/mjsunit/regress/regress-object-assign-deprecated.js » ('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 // 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/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api-arguments.h" 7 #include "src/api-arguments.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 1628
1629 MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, 1629 MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to,
1630 Handle<Object> next_source) { 1630 Handle<Object> next_source) {
1631 // Non-empty strings are the only non-JSReceivers that need to be handled 1631 // Non-empty strings are the only non-JSReceivers that need to be handled
1632 // explicitly by Object.assign. 1632 // explicitly by Object.assign.
1633 if (!next_source->IsJSReceiver()) { 1633 if (!next_source->IsJSReceiver()) {
1634 return Just(!next_source->IsString() || 1634 return Just(!next_source->IsString() ||
1635 String::cast(*next_source)->length() == 0); 1635 String::cast(*next_source)->length() == 0);
1636 } 1636 }
1637 1637
1638 // If the target is deprecated, the object will be updated on first store. If
1639 // the source for that store equals the target, this will invalidate the
1640 // cached representation of the source. Preventively upgrade the target.
1641 // Do this on each iteration since any property load could cause deprecation.
1642 if (to->map()->is_deprecated()) {
1643 JSObject::MigrateInstance(Handle<JSObject>::cast(to));
1644 }
1645
1638 Isolate* isolate = to->GetIsolate(); 1646 Isolate* isolate = to->GetIsolate();
1639 Handle<Map> map(JSReceiver::cast(*next_source)->map(), isolate); 1647 Handle<Map> map(JSReceiver::cast(*next_source)->map(), isolate);
1640 1648
1641 if (!map->IsJSObjectMap()) return Just(false); 1649 if (!map->IsJSObjectMap()) return Just(false);
1642 if (!map->OnlyHasSimpleProperties()) return Just(false); 1650 if (!map->OnlyHasSimpleProperties()) return Just(false);
1643 1651
1644 Handle<JSObject> from = Handle<JSObject>::cast(next_source); 1652 Handle<JSObject> from = Handle<JSObject>::cast(next_source);
1645 if (from->elements() != isolate->heap()->empty_fixed_array()) { 1653 if (from->elements() != isolate->heap()->empty_fixed_array()) {
1646 return Just(false); 1654 return Just(false);
1647 } 1655 }
(...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after
5351 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) 5359 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
5352 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 5360 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
5353 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 5361 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
5354 #undef DEFINE_BUILTIN_ACCESSOR_C 5362 #undef DEFINE_BUILTIN_ACCESSOR_C
5355 #undef DEFINE_BUILTIN_ACCESSOR_A 5363 #undef DEFINE_BUILTIN_ACCESSOR_A
5356 #undef DEFINE_BUILTIN_ACCESSOR_T 5364 #undef DEFINE_BUILTIN_ACCESSOR_T
5357 #undef DEFINE_BUILTIN_ACCESSOR_H 5365 #undef DEFINE_BUILTIN_ACCESSOR_H
5358 5366
5359 } // namespace internal 5367 } // namespace internal
5360 } // namespace v8 5368 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-object-assign-deprecated.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698