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

Side by Side Diff: src/objects/literal-objects.cc

Issue 2663513002: [objects.h splitting] Move out ConstantElementsPair and BoileplateDescriptor. (Closed)
Patch Set: moving constant_elements_kind to ast.cc Created 3 years, 10 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/literal-objects.h ('k') | src/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/objects/literal-objects.h"
6
7 #include "src/factory.h"
8 #include "src/isolate.h"
9 #include "src/objects-inl.h"
10
11 namespace v8 {
12 namespace internal {
13
14 Object* BoilerplateDescription::name(int index) const {
15 // get() already checks for out of bounds access, but we do not want to allow
16 // access to the last element, if it is the number of properties.
17 DCHECK_NE(size(), index);
18 return get(2 * index);
19 }
20
21 Object* BoilerplateDescription::value(int index) const {
22 return get(2 * index + 1);
23 }
24
25 int BoilerplateDescription::size() const {
26 DCHECK_EQ(0, (length() - (this->has_number_of_properties() ? 1 : 0)) % 2);
27 // Rounding is intended.
28 return length() / 2;
29 }
30
31 int BoilerplateDescription::backing_store_size() const {
32 if (has_number_of_properties()) {
33 // If present, the last entry contains the number of properties.
34 return Smi::cast(this->get(length() - 1))->value();
35 }
36 // If the number is not given explicitly, we assume there are no
37 // properties with computed names.
38 return size();
39 }
40
41 void BoilerplateDescription::set_backing_store_size(Isolate* isolate,
42 int backing_store_size) {
43 DCHECK(has_number_of_properties());
44 DCHECK_NE(size(), backing_store_size);
45 Handle<Object> backing_store_size_obj =
46 isolate->factory()->NewNumberFromInt(backing_store_size);
47 set(length() - 1, *backing_store_size_obj);
48 }
49
50 bool BoilerplateDescription::has_number_of_properties() const {
51 return length() % 2 != 0;
52 }
53
54 } // namespace internal
55 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects/literal-objects.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698