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

Side by Side Diff: src/factory.cc

Issue 1406113007: Merge GlobalObject with JSGlobalObject. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/factory.h ('k') | src/full-codegen/arm/full-codegen-arm.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 Handle<Map> map = NewMap(JS_MODULE_TYPE, JSModule::kSize); 1485 Handle<Map> map = NewMap(JS_MODULE_TYPE, JSModule::kSize);
1486 // Allocate the object based on the map. 1486 // Allocate the object based on the map.
1487 Handle<JSModule> module = 1487 Handle<JSModule> module =
1488 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED)); 1488 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED));
1489 module->set_context(*context); 1489 module->set_context(*context);
1490 module->set_scope_info(*scope_info); 1490 module->set_scope_info(*scope_info);
1491 return module; 1491 return module;
1492 } 1492 }
1493 1493
1494 1494
1495 Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) { 1495 Handle<JSGlobalObject> Factory::NewJSGlobalObject(
1496 Handle<JSFunction> constructor) {
1496 DCHECK(constructor->has_initial_map()); 1497 DCHECK(constructor->has_initial_map());
1497 Handle<Map> map(constructor->initial_map()); 1498 Handle<Map> map(constructor->initial_map());
1498 DCHECK(map->is_dictionary_map()); 1499 DCHECK(map->is_dictionary_map());
1499 1500
1500 // Make sure no field properties are described in the initial map. 1501 // Make sure no field properties are described in the initial map.
1501 // This guarantees us that normalizing the properties does not 1502 // This guarantees us that normalizing the properties does not
1502 // require us to change property values to PropertyCells. 1503 // require us to change property values to PropertyCells.
1503 DCHECK(map->NextFreePropertyIndex() == 0); 1504 DCHECK(map->NextFreePropertyIndex() == 0);
1504 1505
1505 // Make sure we don't have a ton of pre-allocated slots in the 1506 // Make sure we don't have a ton of pre-allocated slots in the
(...skipping 21 matching lines...) Expand all
1527 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, 1528 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1,
1528 PropertyCellType::kMutable); 1529 PropertyCellType::kMutable);
1529 Handle<Name> name(descs->GetKey(i)); 1530 Handle<Name> name(descs->GetKey(i));
1530 Handle<PropertyCell> cell = NewPropertyCell(); 1531 Handle<PropertyCell> cell = NewPropertyCell();
1531 cell->set_value(descs->GetCallbacksObject(i)); 1532 cell->set_value(descs->GetCallbacksObject(i));
1532 // |dictionary| already contains enough space for all properties. 1533 // |dictionary| already contains enough space for all properties.
1533 USE(GlobalDictionary::Add(dictionary, name, cell, d)); 1534 USE(GlobalDictionary::Add(dictionary, name, cell, d));
1534 } 1535 }
1535 1536
1536 // Allocate the global object and initialize it with the backing store. 1537 // Allocate the global object and initialize it with the backing store.
1537 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_SPACE); 1538 Handle<JSGlobalObject> global = New<JSGlobalObject>(map, OLD_SPACE);
1538 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map); 1539 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map);
1539 1540
1540 // Create a new map for the global object. 1541 // Create a new map for the global object.
1541 Handle<Map> new_map = Map::CopyDropDescriptors(map); 1542 Handle<Map> new_map = Map::CopyDropDescriptors(map);
1542 new_map->set_dictionary_map(true); 1543 new_map->set_dictionary_map(true);
1543 1544
1544 // Set up the global object as a normalized object. 1545 // Set up the global object as a normalized object.
1545 global->set_map(*new_map); 1546 global->set_map(*new_map);
1546 global->set_properties(*dictionary); 1547 global->set_properties(*dictionary);
1547 1548
1548 // Make sure result is a global object with properties in dictionary. 1549 // Make sure result is a global object with properties in dictionary.
1549 DCHECK(global->IsGlobalObject() && !global->HasFastProperties()); 1550 DCHECK(global->IsJSGlobalObject() && !global->HasFastProperties());
1550 return global; 1551 return global;
1551 } 1552 }
1552 1553
1553 1554
1554 Handle<JSObject> Factory::NewJSObjectFromMap( 1555 Handle<JSObject> Factory::NewJSObjectFromMap(
1555 Handle<Map> map, 1556 Handle<Map> map,
1556 PretenureFlag pretenure, 1557 PretenureFlag pretenure,
1557 Handle<AllocationSite> allocation_site) { 1558 Handle<AllocationSite> allocation_site) {
1558 CALL_HEAP_FUNCTION( 1559 CALL_HEAP_FUNCTION(
1559 isolate(), 1560 isolate(),
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 } 2391 }
2391 2392
2392 2393
2393 Handle<Object> Factory::ToBoolean(bool value) { 2394 Handle<Object> Factory::ToBoolean(bool value) {
2394 return value ? true_value() : false_value(); 2395 return value ? true_value() : false_value();
2395 } 2396 }
2396 2397
2397 2398
2398 } // namespace internal 2399 } // namespace internal
2399 } // namespace v8 2400 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/full-codegen/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698