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

Side by Side Diff: src/factory.h

Issue 219233002: Cleanup bootstrapper, execution and factory modules. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/execution.cc ('k') | src/factory.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 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Use of this source code is governed by a BSD-style license that can be
3 // modification, are permitted provided that the following conditions are 3 // found in the LICENSE file.
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 4
28 #ifndef V8_FACTORY_H_ 5 #ifndef V8_FACTORY_H_
29 #define V8_FACTORY_H_ 6 #define V8_FACTORY_H_
30 7
31 #include "globals.h" 8 #include "isolate.h"
32 #include "handles.h"
33 #include "heap.h"
34 9
35 namespace v8 { 10 namespace v8 {
36 namespace internal { 11 namespace internal {
37 12
38 // Interface for handle based allocation. 13 // Interface for handle based allocation.
39 14
40 class Factory { 15 class Factory V8_FINAL {
41 public: 16 public:
42 // Allocate a new boxed value. 17 // Allocate a new boxed value.
43 Handle<Box> NewBox( 18 Handle<Box> NewBox(
44 Handle<Object> value, 19 Handle<Object> value,
45 PretenureFlag pretenure = NOT_TENURED); 20 PretenureFlag pretenure = NOT_TENURED);
46 21
47 // Allocates a fixed array initialized with undefined values. 22 // Allocates a fixed array initialized with undefined values.
48 Handle<FixedArray> NewFixedArray( 23 Handle<FixedArray> NewFixedArray(
49 int size, 24 int size,
50 PretenureFlag pretenure = NOT_TENURED); 25 PretenureFlag pretenure = NOT_TENURED);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 Handle<ConstantPoolArray> array); 280 Handle<ConstantPoolArray> array);
306 281
307 // Numbers (e.g. literals) are pretenured by the parser. 282 // Numbers (e.g. literals) are pretenured by the parser.
308 Handle<Object> NewNumber(double value, 283 Handle<Object> NewNumber(double value,
309 PretenureFlag pretenure = NOT_TENURED); 284 PretenureFlag pretenure = NOT_TENURED);
310 285
311 Handle<Object> NewNumberFromInt(int32_t value, 286 Handle<Object> NewNumberFromInt(int32_t value,
312 PretenureFlag pretenure = NOT_TENURED); 287 PretenureFlag pretenure = NOT_TENURED);
313 Handle<Object> NewNumberFromUint(uint32_t value, 288 Handle<Object> NewNumberFromUint(uint32_t value,
314 PretenureFlag pretenure = NOT_TENURED); 289 PretenureFlag pretenure = NOT_TENURED);
315 inline Handle<Object> NewNumberFromSize(size_t value, 290 Handle<Object> NewNumberFromSize(size_t value,
316 PretenureFlag pretenure = NOT_TENURED); 291 PretenureFlag pretenure = NOT_TENURED) {
292 if (Smi::IsValid(static_cast<intptr_t>(value))) {
293 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
294 isolate());
295 }
296 return NewNumber(static_cast<double>(value), pretenure);
297 }
317 Handle<HeapNumber> NewHeapNumber(double value, 298 Handle<HeapNumber> NewHeapNumber(double value,
318 PretenureFlag pretenure = NOT_TENURED); 299 PretenureFlag pretenure = NOT_TENURED);
319 300
320 301
321 // These objects are used by the api to create env-independent data 302 // These objects are used by the api to create env-independent data
322 // structures in the heap. 303 // structures in the heap.
323 Handle<JSObject> NewNeanderObject(); 304 Handle<JSObject> NewNeanderObject();
324 305
325 Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length); 306 Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length);
326 307
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 593
613 // Create a new map cache. 594 // Create a new map cache.
614 Handle<MapCache> NewMapCache(int at_least_space_for); 595 Handle<MapCache> NewMapCache(int at_least_space_for);
615 596
616 // Update the map cache in the native context with (keys, map) 597 // Update the map cache in the native context with (keys, map)
617 Handle<MapCache> AddToMapCache(Handle<Context> context, 598 Handle<MapCache> AddToMapCache(Handle<Context> context,
618 Handle<FixedArray> keys, 599 Handle<FixedArray> keys,
619 Handle<Map> map); 600 Handle<Map> map);
620 }; 601 };
621 602
622
623 Handle<Object> Factory::NewNumberFromSize(size_t value,
624 PretenureFlag pretenure) {
625 if (Smi::IsValid(static_cast<intptr_t>(value))) {
626 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
627 isolate());
628 } else {
629 return NewNumber(static_cast<double>(value), pretenure);
630 }
631 }
632
633
634 } } // namespace v8::internal 603 } } // namespace v8::internal
635 604
636 #endif // V8_FACTORY_H_ 605 #endif // V8_FACTORY_H_
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698