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

Side by Side Diff: src/factory.cc

Issue 23182003: Push SetAccessor to Template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase, grokdump Created 7 years, 3 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/api.cc ('k') | src/macros.py » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 1453
1454 // Set instance call-as-function information in the map. 1454 // Set instance call-as-function information in the map.
1455 if (!obj->instance_call_handler()->IsUndefined()) { 1455 if (!obj->instance_call_handler()->IsUndefined()) {
1456 map->set_has_instance_call_handler(); 1456 map->set_has_instance_call_handler();
1457 } 1457 }
1458 1458
1459 result->shared()->set_function_data(*obj); 1459 result->shared()->set_function_data(*obj);
1460 result->shared()->set_construct_stub(*construct_stub); 1460 result->shared()->set_construct_stub(*construct_stub);
1461 result->shared()->DontAdaptArguments(); 1461 result->shared()->DontAdaptArguments();
1462 1462
1463 // Recursively copy parent templates' accessors, 'data' may be modified. 1463 // Recursively copy parent instance templates' accessors,
1464 // 'data' may be modified.
1464 int max_number_of_additional_properties = 0; 1465 int max_number_of_additional_properties = 0;
1466 int max_number_of_static_properties = 0;
1465 FunctionTemplateInfo* info = *obj; 1467 FunctionTemplateInfo* info = *obj;
1466 while (true) { 1468 while (true) {
1467 Object* props = info->property_accessors(); 1469 if (!info->instance_template()->IsUndefined()) {
1468 if (!props->IsUndefined()) { 1470 Object* props =
1469 Handle<Object> props_handle(props, isolate()); 1471 ObjectTemplateInfo::cast(
1470 NeanderArray props_array(props_handle); 1472 info->instance_template())->property_accessors();
1471 max_number_of_additional_properties += props_array.length(); 1473 if (!props->IsUndefined()) {
1474 Handle<Object> props_handle(props, isolate());
1475 NeanderArray props_array(props_handle);
1476 max_number_of_additional_properties += props_array.length();
1477 }
1478 }
1479 if (!info->property_accessors()->IsUndefined()) {
1480 Object* props = info->property_accessors();
1481 if (!props->IsUndefined()) {
1482 Handle<Object> props_handle(props, isolate());
1483 NeanderArray props_array(props_handle);
1484 max_number_of_static_properties += props_array.length();
1485 }
1472 } 1486 }
1473 Object* parent = info->parent_template(); 1487 Object* parent = info->parent_template();
1474 if (parent->IsUndefined()) break; 1488 if (parent->IsUndefined()) break;
1475 info = FunctionTemplateInfo::cast(parent); 1489 info = FunctionTemplateInfo::cast(parent);
1476 } 1490 }
1477 1491
1478 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); 1492 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties);
1479 1493
1494 // Use a temporary FixedArray to acculumate static accessors
1495 int valid_descriptors = 0;
1496 Handle<FixedArray> array;
1497 if (max_number_of_static_properties > 0) {
1498 array = NewFixedArray(max_number_of_static_properties);
1499 }
1500
1480 while (true) { 1501 while (true) {
1481 Handle<Object> props = Handle<Object>(obj->property_accessors(), 1502 // Install instance descriptors
1482 isolate()); 1503 if (!obj->instance_template()->IsUndefined()) {
1483 if (!props->IsUndefined()) { 1504 Handle<ObjectTemplateInfo> instance =
1484 Map::AppendCallbackDescriptors(map, props); 1505 Handle<ObjectTemplateInfo>(
1506 ObjectTemplateInfo::cast(obj->instance_template()), isolate());
1507 Handle<Object> props = Handle<Object>(instance->property_accessors(),
1508 isolate());
1509 if (!props->IsUndefined()) {
1510 Map::AppendCallbackDescriptors(map, props);
1511 }
1485 } 1512 }
1513 // Accumulate static accessors
1514 if (!obj->property_accessors()->IsUndefined()) {
1515 Handle<Object> props = Handle<Object>(obj->property_accessors(),
1516 isolate());
1517 valid_descriptors =
1518 AccessorInfo::AppendUnique(props, array, valid_descriptors);
1519 }
1520 // Climb parent chain
1486 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); 1521 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate());
1487 if (parent->IsUndefined()) break; 1522 if (parent->IsUndefined()) break;
1488 obj = Handle<FunctionTemplateInfo>::cast(parent); 1523 obj = Handle<FunctionTemplateInfo>::cast(parent);
1489 } 1524 }
1490 1525
1526 // Install accumulated static accessors
1527 for (int i = 0; i < valid_descriptors; i++) {
1528 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i)));
1529 JSObject::SetAccessor(result, accessor);
1530 }
1531
1491 ASSERT(result->shared()->IsApiFunction()); 1532 ASSERT(result->shared()->IsApiFunction());
1492 return result; 1533 return result;
1493 } 1534 }
1494 1535
1495 1536
1496 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { 1537 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) {
1497 CALL_HEAP_FUNCTION(isolate(), 1538 CALL_HEAP_FUNCTION(isolate(),
1498 MapCache::Allocate(isolate()->heap(), 1539 MapCache::Allocate(isolate()->heap(),
1499 at_least_space_for), 1540 at_least_space_for),
1500 MapCache); 1541 MapCache);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 return Handle<Object>::null(); 1645 return Handle<Object>::null();
1605 } 1646 }
1606 1647
1607 1648
1608 Handle<Object> Factory::ToBoolean(bool value) { 1649 Handle<Object> Factory::ToBoolean(bool value) {
1609 return value ? true_value() : false_value(); 1650 return value ? true_value() : false_value();
1610 } 1651 }
1611 1652
1612 1653
1613 } } // namespace v8::internal 1654 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698