Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1460 | 1460 |
| 1461 // Set instance call-as-function information in the map. | 1461 // Set instance call-as-function information in the map. |
| 1462 if (!obj->instance_call_handler()->IsUndefined()) { | 1462 if (!obj->instance_call_handler()->IsUndefined()) { |
| 1463 map->set_has_instance_call_handler(); | 1463 map->set_has_instance_call_handler(); |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 result->shared()->set_function_data(*obj); | 1466 result->shared()->set_function_data(*obj); |
| 1467 result->shared()->set_construct_stub(*construct_stub); | 1467 result->shared()->set_construct_stub(*construct_stub); |
| 1468 result->shared()->DontAdaptArguments(); | 1468 result->shared()->DontAdaptArguments(); |
| 1469 | 1469 |
| 1470 // Recursively copy parent templates' accessors, 'data' may be modified. | 1470 // Recursively copy parent instance templates' accessors, |
| 1471 // 'data' may be modified. | |
| 1471 int max_number_of_additional_properties = 0; | 1472 int max_number_of_additional_properties = 0; |
| 1473 int max_number_of_static_properties = 0; | |
| 1472 FunctionTemplateInfo* info = *obj; | 1474 FunctionTemplateInfo* info = *obj; |
| 1473 while (true) { | 1475 while (true) { |
| 1474 Object* props = info->property_accessors(); | 1476 if (!info->instance_template()->IsUndefined()) { |
| 1475 if (!props->IsUndefined()) { | 1477 Object* props = |
| 1476 Handle<Object> props_handle(props, isolate()); | 1478 ObjectTemplateInfo::cast( |
| 1477 NeanderArray props_array(props_handle); | 1479 info->instance_template())->property_accessors(); |
| 1478 max_number_of_additional_properties += props_array.length(); | 1480 if (!props->IsUndefined()) { |
| 1481 Handle<Object> props_handle(props, isolate()); | |
| 1482 NeanderArray props_array(props_handle); | |
| 1483 max_number_of_additional_properties += props_array.length(); | |
| 1484 } | |
| 1485 } | |
| 1486 if (!info->property_accessors()->IsUndefined()) { | |
| 1487 Object* props = info->property_accessors(); | |
| 1488 if (!props->IsUndefined()) { | |
| 1489 Handle<Object> props_handle(props, isolate()); | |
| 1490 NeanderArray props_array(props_handle); | |
| 1491 max_number_of_static_properties += props_array.length(); | |
| 1492 } | |
| 1479 } | 1493 } |
| 1480 Object* parent = info->parent_template(); | 1494 Object* parent = info->parent_template(); |
| 1481 if (parent->IsUndefined()) break; | 1495 if (parent->IsUndefined()) break; |
| 1482 info = FunctionTemplateInfo::cast(parent); | 1496 info = FunctionTemplateInfo::cast(parent); |
| 1483 } | 1497 } |
| 1484 | 1498 |
| 1485 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); | 1499 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); |
| 1486 | 1500 |
| 1501 // Use a temporary FixedArray to acculumate static accessors | |
| 1502 int valid_descriptors = 0; | |
| 1503 Handle<FixedArray> array; | |
| 1504 if (max_number_of_static_properties > 0) { | |
| 1505 array = NewFixedArray(max_number_of_static_properties); | |
| 1506 } | |
| 1507 | |
| 1487 while (true) { | 1508 while (true) { |
| 1488 Handle<Object> props = Handle<Object>(obj->property_accessors(), | 1509 // Install instance descriptors |
| 1489 isolate()); | 1510 if (!obj->instance_template()->IsUndefined()) { |
| 1490 if (!props->IsUndefined()) { | 1511 Handle<ObjectTemplateInfo> instance = |
| 1491 Map::AppendCallbackDescriptors(map, props); | 1512 Handle<ObjectTemplateInfo>( |
| 1513 ObjectTemplateInfo::cast(obj->instance_template()), isolate()); | |
| 1514 Handle<Object> props = Handle<Object>(instance->property_accessors(), | |
| 1515 isolate()); | |
| 1516 if (!props->IsUndefined()) { | |
| 1517 Map::AppendCallbackDescriptors(map, props); | |
| 1518 } | |
| 1492 } | 1519 } |
| 1520 // Accumulate static accessors | |
| 1521 if (!obj->property_accessors()->IsUndefined()) { | |
| 1522 Handle<Object> props = Handle<Object>(obj->property_accessors(), | |
| 1523 isolate()); | |
| 1524 valid_descriptors = | |
| 1525 AccessorInfo::AppendUnique(props, array, valid_descriptors); | |
| 1526 } | |
| 1527 // Climb parent chain | |
| 1493 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); | 1528 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); |
| 1494 if (parent->IsUndefined()) break; | 1529 if (parent->IsUndefined()) break; |
| 1495 obj = Handle<FunctionTemplateInfo>::cast(parent); | 1530 obj = Handle<FunctionTemplateInfo>::cast(parent); |
| 1496 } | 1531 } |
| 1497 | 1532 |
| 1533 // Install accumulated static accessors | |
| 1534 for (int i = 0; i < valid_descriptors; i++) { | |
| 1535 AccessorInfo* value = AccessorInfo::cast(array->get(i)); | |
| 1536 Handle<AccessorInfo> accessor(value, isolate()); | |
|
Michael Starzinger
2013/09/03 14:00:57
nit: This can be simplified to just ...
Handle<Ac
| |
| 1537 SetAccessor(result, accessor); | |
| 1538 } | |
| 1539 | |
| 1498 ASSERT(result->shared()->IsApiFunction()); | 1540 ASSERT(result->shared()->IsApiFunction()); |
| 1499 return result; | 1541 return result; |
| 1500 } | 1542 } |
| 1501 | 1543 |
| 1502 | 1544 |
| 1503 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { | 1545 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { |
| 1504 CALL_HEAP_FUNCTION(isolate(), | 1546 CALL_HEAP_FUNCTION(isolate(), |
| 1505 MapCache::Allocate(isolate()->heap(), | 1547 MapCache::Allocate(isolate()->heap(), |
| 1506 at_least_space_for), | 1548 at_least_space_for), |
| 1507 MapCache); | 1549 MapCache); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 return Handle<Object>::null(); | 1652 return Handle<Object>::null(); |
| 1611 } | 1653 } |
| 1612 | 1654 |
| 1613 | 1655 |
| 1614 Handle<Object> Factory::ToBoolean(bool value) { | 1656 Handle<Object> Factory::ToBoolean(bool value) { |
| 1615 return value ? true_value() : false_value(); | 1657 return value ? true_value() : false_value(); |
| 1616 } | 1658 } |
| 1617 | 1659 |
| 1618 | 1660 |
| 1619 } } // namespace v8::internal | 1661 } } // namespace v8::internal |
| OLD | NEW |