| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ObjectHashTable::Allocate(isolate()->heap(), | 123 ObjectHashTable::Allocate(isolate()->heap(), |
| 124 at_least_space_for), | 124 at_least_space_for), |
| 125 ObjectHashTable); | 125 ObjectHashTable); |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors, | 129 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors, |
| 130 int slack) { | 130 int slack) { |
| 131 ASSERT(0 <= number_of_descriptors); | 131 ASSERT(0 <= number_of_descriptors); |
| 132 CALL_HEAP_FUNCTION(isolate(), | 132 CALL_HEAP_FUNCTION(isolate(), |
| 133 DescriptorArray::Allocate(number_of_descriptors, slack), | 133 DescriptorArray::Allocate( |
| 134 isolate(), number_of_descriptors, slack), |
| 134 DescriptorArray); | 135 DescriptorArray); |
| 135 } | 136 } |
| 136 | 137 |
| 137 | 138 |
| 138 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( | 139 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( |
| 139 int deopt_entry_count, | 140 int deopt_entry_count, |
| 140 PretenureFlag pretenure) { | 141 PretenureFlag pretenure) { |
| 141 ASSERT(deopt_entry_count > 0); | 142 ASSERT(deopt_entry_count > 0); |
| 142 CALL_HEAP_FUNCTION(isolate(), | 143 CALL_HEAP_FUNCTION(isolate(), |
| 143 DeoptimizationInputData::Allocate(deopt_entry_count, | 144 DeoptimizationInputData::Allocate(deopt_entry_count, |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 658 } |
| 658 result->set_literals(*literals); | 659 result->set_literals(*literals); |
| 659 } | 660 } |
| 660 | 661 |
| 661 if (index > 0) { | 662 if (index > 0) { |
| 662 // Caching of optimized code enabled and optimized code found. | 663 // Caching of optimized code enabled and optimized code found. |
| 663 function_info->InstallFromOptimizedCodeMap(*result, index); | 664 function_info->InstallFromOptimizedCodeMap(*result, index); |
| 664 return result; | 665 return result; |
| 665 } | 666 } |
| 666 | 667 |
| 667 if (V8::UseCrankshaft() && | 668 if (isolate()->use_crankshaft() && |
| 668 FLAG_always_opt && | 669 FLAG_always_opt && |
| 669 result->is_compiled() && | 670 result->is_compiled() && |
| 670 !function_info->is_toplevel() && | 671 !function_info->is_toplevel() && |
| 671 function_info->allows_lazy_compilation() && | 672 function_info->allows_lazy_compilation() && |
| 672 !function_info->optimization_disabled() && | 673 !function_info->optimization_disabled() && |
| 673 !isolate()->DebuggerHasBreakPoints()) { | 674 !isolate()->DebuggerHasBreakPoints()) { |
| 674 result->MarkForLazyRecompilation(); | 675 result->MarkForLazyRecompilation(); |
| 675 } | 676 } |
| 676 return result; | 677 return result; |
| 677 } | 678 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 Vector<char> v(buffer, kBufferSize); | 800 Vector<char> v(buffer, kBufferSize); |
| 800 OS::StrNCpy(v, message, space); | 801 OS::StrNCpy(v, message, space); |
| 801 space -= Min(space, strlen(message)); | 802 space -= Min(space, strlen(message)); |
| 802 p = &buffer[kBufferSize] - space; | 803 p = &buffer[kBufferSize] - space; |
| 803 | 804 |
| 804 for (unsigned i = 0; i < ARRAY_SIZE(args); i++) { | 805 for (unsigned i = 0; i < ARRAY_SIZE(args); i++) { |
| 805 if (space > 0) { | 806 if (space > 0) { |
| 806 *p++ = ' '; | 807 *p++ = ' '; |
| 807 space--; | 808 space--; |
| 808 if (space > 0) { | 809 if (space > 0) { |
| 809 MaybeObject* maybe_arg = args->GetElement(i); | 810 MaybeObject* maybe_arg = args->GetElement(isolate(), i); |
| 810 Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg)); | 811 Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg)); |
| 811 const char* arg = *arg_str->ToCString(); | 812 const char* arg = *arg_str->ToCString(); |
| 812 Vector<char> v2(p, static_cast<int>(space)); | 813 Vector<char> v2(p, static_cast<int>(space)); |
| 813 OS::StrNCpy(v2, arg, space); | 814 OS::StrNCpy(v2, arg, space); |
| 814 space -= Min(space, strlen(arg)); | 815 space -= Min(space, strlen(arg)); |
| 815 p = &buffer[kBufferSize] - space; | 816 p = &buffer[kBufferSize] - space; |
| 816 } | 817 } |
| 817 } | 818 } |
| 818 } | 819 } |
| 819 if (space > 0) { | 820 if (space > 0) { |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 Handle<String> name, | 1315 Handle<String> name, |
| 1315 LanguageMode language_mode) { | 1316 LanguageMode language_mode) { |
| 1316 Handle<JSFunction> fun = | 1317 Handle<JSFunction> fun = |
| 1317 NewFunctionWithoutPrototypeHelper(name, language_mode); | 1318 NewFunctionWithoutPrototypeHelper(name, language_mode); |
| 1318 fun->set_context(isolate()->context()->native_context()); | 1319 fun->set_context(isolate()->context()->native_context()); |
| 1319 return fun; | 1320 return fun; |
| 1320 } | 1321 } |
| 1321 | 1322 |
| 1322 | 1323 |
| 1323 Handle<Object> Factory::ToObject(Handle<Object> object) { | 1324 Handle<Object> Factory::ToObject(Handle<Object> object) { |
| 1324 CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object); | 1325 CALL_HEAP_FUNCTION(isolate(), object->ToObject(isolate()), Object); |
| 1325 } | 1326 } |
| 1326 | 1327 |
| 1327 | 1328 |
| 1328 Handle<Object> Factory::ToObject(Handle<Object> object, | 1329 Handle<Object> Factory::ToObject(Handle<Object> object, |
| 1329 Handle<Context> native_context) { | 1330 Handle<Context> native_context) { |
| 1330 CALL_HEAP_FUNCTION(isolate(), object->ToObject(*native_context), Object); | 1331 CALL_HEAP_FUNCTION(isolate(), object->ToObject(*native_context), Object); |
| 1331 } | 1332 } |
| 1332 | 1333 |
| 1333 | 1334 |
| 1334 #ifdef ENABLE_DEBUGGER_SUPPORT | 1335 #ifdef ENABLE_DEBUGGER_SUPPORT |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 | 1454 |
| 1454 // Set instance call-as-function information in the map. | 1455 // Set instance call-as-function information in the map. |
| 1455 if (!obj->instance_call_handler()->IsUndefined()) { | 1456 if (!obj->instance_call_handler()->IsUndefined()) { |
| 1456 map->set_has_instance_call_handler(); | 1457 map->set_has_instance_call_handler(); |
| 1457 } | 1458 } |
| 1458 | 1459 |
| 1459 result->shared()->set_function_data(*obj); | 1460 result->shared()->set_function_data(*obj); |
| 1460 result->shared()->set_construct_stub(*construct_stub); | 1461 result->shared()->set_construct_stub(*construct_stub); |
| 1461 result->shared()->DontAdaptArguments(); | 1462 result->shared()->DontAdaptArguments(); |
| 1462 | 1463 |
| 1463 // Recursively copy parent templates' accessors, 'data' may be modified. | 1464 // Recursively copy parent instance templates' accessors, |
| 1465 // 'data' may be modified. |
| 1464 int max_number_of_additional_properties = 0; | 1466 int max_number_of_additional_properties = 0; |
| 1467 int max_number_of_static_properties = 0; |
| 1465 FunctionTemplateInfo* info = *obj; | 1468 FunctionTemplateInfo* info = *obj; |
| 1466 while (true) { | 1469 while (true) { |
| 1467 Object* props = info->property_accessors(); | 1470 if (!info->instance_template()->IsUndefined()) { |
| 1468 if (!props->IsUndefined()) { | 1471 Object* props = |
| 1469 Handle<Object> props_handle(props, isolate()); | 1472 ObjectTemplateInfo::cast( |
| 1470 NeanderArray props_array(props_handle); | 1473 info->instance_template())->property_accessors(); |
| 1471 max_number_of_additional_properties += props_array.length(); | 1474 if (!props->IsUndefined()) { |
| 1475 Handle<Object> props_handle(props, isolate()); |
| 1476 NeanderArray props_array(props_handle); |
| 1477 max_number_of_additional_properties += props_array.length(); |
| 1478 } |
| 1479 } |
| 1480 if (!info->property_accessors()->IsUndefined()) { |
| 1481 Object* props = info->property_accessors(); |
| 1482 if (!props->IsUndefined()) { |
| 1483 Handle<Object> props_handle(props, isolate()); |
| 1484 NeanderArray props_array(props_handle); |
| 1485 max_number_of_static_properties += props_array.length(); |
| 1486 } |
| 1472 } | 1487 } |
| 1473 Object* parent = info->parent_template(); | 1488 Object* parent = info->parent_template(); |
| 1474 if (parent->IsUndefined()) break; | 1489 if (parent->IsUndefined()) break; |
| 1475 info = FunctionTemplateInfo::cast(parent); | 1490 info = FunctionTemplateInfo::cast(parent); |
| 1476 } | 1491 } |
| 1477 | 1492 |
| 1478 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); | 1493 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); |
| 1479 | 1494 |
| 1495 // Use a temporary FixedArray to acculumate static accessors |
| 1496 int valid_descriptors = 0; |
| 1497 Handle<FixedArray> array; |
| 1498 if (max_number_of_static_properties > 0) { |
| 1499 array = NewFixedArray(max_number_of_static_properties); |
| 1500 } |
| 1501 |
| 1480 while (true) { | 1502 while (true) { |
| 1481 Handle<Object> props = Handle<Object>(obj->property_accessors(), | 1503 // Install instance descriptors |
| 1482 isolate()); | 1504 if (!obj->instance_template()->IsUndefined()) { |
| 1483 if (!props->IsUndefined()) { | 1505 Handle<ObjectTemplateInfo> instance = |
| 1484 Map::AppendCallbackDescriptors(map, props); | 1506 Handle<ObjectTemplateInfo>( |
| 1507 ObjectTemplateInfo::cast(obj->instance_template()), isolate()); |
| 1508 Handle<Object> props = Handle<Object>(instance->property_accessors(), |
| 1509 isolate()); |
| 1510 if (!props->IsUndefined()) { |
| 1511 Map::AppendCallbackDescriptors(map, props); |
| 1512 } |
| 1485 } | 1513 } |
| 1514 // Accumulate static accessors |
| 1515 if (!obj->property_accessors()->IsUndefined()) { |
| 1516 Handle<Object> props = Handle<Object>(obj->property_accessors(), |
| 1517 isolate()); |
| 1518 valid_descriptors = |
| 1519 AccessorInfo::AppendUnique(props, array, valid_descriptors); |
| 1520 } |
| 1521 // Climb parent chain |
| 1486 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); | 1522 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); |
| 1487 if (parent->IsUndefined()) break; | 1523 if (parent->IsUndefined()) break; |
| 1488 obj = Handle<FunctionTemplateInfo>::cast(parent); | 1524 obj = Handle<FunctionTemplateInfo>::cast(parent); |
| 1489 } | 1525 } |
| 1490 | 1526 |
| 1527 // Install accumulated static accessors |
| 1528 for (int i = 0; i < valid_descriptors; i++) { |
| 1529 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); |
| 1530 JSObject::SetAccessor(result, accessor); |
| 1531 } |
| 1532 |
| 1491 ASSERT(result->shared()->IsApiFunction()); | 1533 ASSERT(result->shared()->IsApiFunction()); |
| 1492 return result; | 1534 return result; |
| 1493 } | 1535 } |
| 1494 | 1536 |
| 1495 | 1537 |
| 1496 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { | 1538 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { |
| 1497 CALL_HEAP_FUNCTION(isolate(), | 1539 CALL_HEAP_FUNCTION(isolate(), |
| 1498 MapCache::Allocate(isolate()->heap(), | 1540 MapCache::Allocate(isolate()->heap(), |
| 1499 at_least_space_for), | 1541 at_least_space_for), |
| 1500 MapCache); | 1542 MapCache); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 | 1621 |
| 1580 | 1622 |
| 1581 | 1623 |
| 1582 void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc, | 1624 void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc, |
| 1583 Handle<JSObject> instance, | 1625 Handle<JSObject> instance, |
| 1584 bool* pending_exception) { | 1626 bool* pending_exception) { |
| 1585 // Configure the instance by adding the properties specified by the | 1627 // Configure the instance by adding the properties specified by the |
| 1586 // instance template. | 1628 // instance template. |
| 1587 Handle<Object> instance_template(desc->instance_template(), isolate()); | 1629 Handle<Object> instance_template(desc->instance_template(), isolate()); |
| 1588 if (!instance_template->IsUndefined()) { | 1630 if (!instance_template->IsUndefined()) { |
| 1589 Execution::ConfigureInstance(instance, | 1631 Execution::ConfigureInstance(isolate(), |
| 1632 instance, |
| 1590 instance_template, | 1633 instance_template, |
| 1591 pending_exception); | 1634 pending_exception); |
| 1592 } else { | 1635 } else { |
| 1593 *pending_exception = false; | 1636 *pending_exception = false; |
| 1594 } | 1637 } |
| 1595 } | 1638 } |
| 1596 | 1639 |
| 1597 | 1640 |
| 1598 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { | 1641 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { |
| 1599 Heap* h = isolate()->heap(); | 1642 Heap* h = isolate()->heap(); |
| 1600 if (name->Equals(h->undefined_string())) return undefined_value(); | 1643 if (name->Equals(h->undefined_string())) return undefined_value(); |
| 1601 if (name->Equals(h->nan_string())) return nan_value(); | 1644 if (name->Equals(h->nan_string())) return nan_value(); |
| 1602 if (name->Equals(h->infinity_string())) return infinity_value(); | 1645 if (name->Equals(h->infinity_string())) return infinity_value(); |
| 1603 return Handle<Object>::null(); | 1646 return Handle<Object>::null(); |
| 1604 } | 1647 } |
| 1605 | 1648 |
| 1606 | 1649 |
| 1607 Handle<Object> Factory::ToBoolean(bool value) { | 1650 Handle<Object> Factory::ToBoolean(bool value) { |
| 1608 return value ? true_value() : false_value(); | 1651 return value ? true_value() : false_value(); |
| 1609 } | 1652 } |
| 1610 | 1653 |
| 1611 | 1654 |
| 1612 } } // namespace v8::internal | 1655 } } // namespace v8::internal |
| OLD | NEW |