Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); | 746 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); |
| 747 return error_string; | 747 return error_string; |
| 748 } | 748 } |
| 749 | 749 |
| 750 | 750 |
| 751 Handle<Object> Factory::NewError(const char* maker, | 751 Handle<Object> Factory::NewError(const char* maker, |
| 752 const char* type, | 752 const char* type, |
| 753 Handle<JSArray> args) { | 753 Handle<JSArray> args) { |
| 754 Handle<String> make_str = LookupUtf8Symbol(maker); | 754 Handle<String> make_str = LookupUtf8Symbol(maker); |
| 755 Handle<Object> fun_obj( | 755 Handle<Object> fun_obj( |
| 756 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str)); | 756 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str), |
| 757 isolate()); | |
| 757 // If the builtins haven't been properly configured yet this error | 758 // If the builtins haven't been properly configured yet this error |
| 758 // constructor may not have been defined. Bail out. | 759 // constructor may not have been defined. Bail out. |
| 759 if (!fun_obj->IsJSFunction()) { | 760 if (!fun_obj->IsJSFunction()) { |
| 760 return EmergencyNewError(type, args); | 761 return EmergencyNewError(type, args); |
| 761 } | 762 } |
| 762 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); | 763 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); |
| 763 Handle<Object> type_obj = LookupUtf8Symbol(type); | 764 Handle<Object> type_obj = LookupUtf8Symbol(type); |
| 764 Handle<Object> argv[] = { type_obj, args }; | 765 Handle<Object> argv[] = { type_obj, args }; |
| 765 | 766 |
| 766 // Invoke the JavaScript factory method. If an exception is thrown while | 767 // Invoke the JavaScript factory method. If an exception is thrown while |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 NewFunction(Factory::empty_symbol(), | 1269 NewFunction(Factory::empty_symbol(), |
| 1269 type, | 1270 type, |
| 1270 instance_size, | 1271 instance_size, |
| 1271 code, | 1272 code, |
| 1272 true); | 1273 true); |
| 1273 | 1274 |
| 1274 // Set length. | 1275 // Set length. |
| 1275 result->shared()->set_length(obj->length()); | 1276 result->shared()->set_length(obj->length()); |
| 1276 | 1277 |
| 1277 // Set class name. | 1278 // Set class name. |
| 1278 Handle<Object> class_name = Handle<Object>(obj->class_name()); | 1279 Handle<Object> class_name = Handle<Object>(obj->class_name(), isolate()); |
| 1279 if (class_name->IsString()) { | 1280 if (class_name->IsString()) { |
| 1280 result->shared()->set_instance_class_name(*class_name); | 1281 result->shared()->set_instance_class_name(*class_name); |
| 1281 result->shared()->set_name(*class_name); | 1282 result->shared()->set_name(*class_name); |
| 1282 } | 1283 } |
| 1283 | 1284 |
| 1284 Handle<Map> map = Handle<Map>(result->initial_map()); | 1285 Handle<Map> map = Handle<Map>(result->initial_map()); |
| 1285 | 1286 |
| 1286 // Mark as undetectable if needed. | 1287 // Mark as undetectable if needed. |
| 1287 if (obj->undetectable()) { | 1288 if (obj->undetectable()) { |
| 1288 map->set_is_undetectable(); | 1289 map->set_is_undetectable(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1314 result->shared()->set_function_data(*obj); | 1315 result->shared()->set_function_data(*obj); |
| 1315 result->shared()->set_construct_stub(*construct_stub); | 1316 result->shared()->set_construct_stub(*construct_stub); |
| 1316 result->shared()->DontAdaptArguments(); | 1317 result->shared()->DontAdaptArguments(); |
| 1317 | 1318 |
| 1318 // Recursively copy parent templates' accessors, 'data' may be modified. | 1319 // Recursively copy parent templates' accessors, 'data' may be modified. |
| 1319 int max_number_of_additional_properties = 0; | 1320 int max_number_of_additional_properties = 0; |
| 1320 FunctionTemplateInfo* info = *obj; | 1321 FunctionTemplateInfo* info = *obj; |
| 1321 while (true) { | 1322 while (true) { |
| 1322 Object* props = info->property_accessors(); | 1323 Object* props = info->property_accessors(); |
| 1323 if (!props->IsUndefined()) { | 1324 if (!props->IsUndefined()) { |
| 1324 Handle<Object> props_handle(props); | 1325 Handle<Object> props_handle(props, isolate()); |
| 1325 NeanderArray props_array(props_handle); | 1326 NeanderArray props_array(props_handle); |
| 1326 max_number_of_additional_properties += props_array.length(); | 1327 max_number_of_additional_properties += props_array.length(); |
| 1327 } | 1328 } |
| 1328 Object* parent = info->parent_template(); | 1329 Object* parent = info->parent_template(); |
| 1329 if (parent->IsUndefined()) break; | 1330 if (parent->IsUndefined()) break; |
| 1330 info = FunctionTemplateInfo::cast(parent); | 1331 info = FunctionTemplateInfo::cast(parent); |
| 1331 } | 1332 } |
| 1332 | 1333 |
| 1333 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); | 1334 Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); |
| 1334 | 1335 |
| 1335 while (true) { | 1336 while (true) { |
| 1336 Handle<Object> props = Handle<Object>(obj->property_accessors()); | 1337 Handle<Object> props = Handle<Object>(obj->property_accessors(), |
| 1338 isolate()); | |
| 1337 if (!props->IsUndefined()) { | 1339 if (!props->IsUndefined()) { |
| 1338 Map::AppendCallbackDescriptors(map, props); | 1340 Map::AppendCallbackDescriptors(map, props); |
| 1339 } | 1341 } |
| 1340 Handle<Object> parent = Handle<Object>(obj->parent_template()); | 1342 Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); |
| 1341 if (parent->IsUndefined()) break; | 1343 if (parent->IsUndefined()) break; |
| 1342 obj = Handle<FunctionTemplateInfo>::cast(parent); | 1344 obj = Handle<FunctionTemplateInfo>::cast(parent); |
| 1343 } | 1345 } |
| 1344 | 1346 |
| 1345 ASSERT(result->shared()->IsApiFunction()); | 1347 ASSERT(result->shared()->IsApiFunction()); |
| 1346 return result; | 1348 return result; |
| 1347 } | 1349 } |
| 1348 | 1350 |
| 1349 | 1351 |
| 1350 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { | 1352 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { | 1452 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { |
| 1451 Heap* h = isolate()->heap(); | 1453 Heap* h = isolate()->heap(); |
| 1452 if (name->Equals(h->undefined_symbol())) return undefined_value(); | 1454 if (name->Equals(h->undefined_symbol())) return undefined_value(); |
| 1453 if (name->Equals(h->nan_symbol())) return nan_value(); | 1455 if (name->Equals(h->nan_symbol())) return nan_value(); |
| 1454 if (name->Equals(h->infinity_symbol())) return infinity_value(); | 1456 if (name->Equals(h->infinity_symbol())) return infinity_value(); |
| 1455 return Handle<Object>::null(); | 1457 return Handle<Object>::null(); |
| 1456 } | 1458 } |
| 1457 | 1459 |
| 1458 | 1460 |
| 1459 Handle<Object> Factory::ToBoolean(bool value) { | 1461 Handle<Object> Factory::ToBoolean(bool value) { |
| 1460 return Handle<Object>(value | 1462 Heap* heap = isolate()->heap(); |
| 1461 ? isolate()->heap()->true_value() | 1463 Object* obj = value ? heap->true_value() : heap->false_value(); |
| 1462 : isolate()->heap()->false_value()); | 1464 return Handle<Object>(obj, isolate()); |
|
Michael Starzinger
2013/02/25 10:50:58
This can be simplified to "return value ? true_val
Sven Panne
2013/02/25 14:44:43
Done.
| |
| 1463 } | 1465 } |
| 1464 | 1466 |
| 1465 | 1467 |
| 1466 } } // namespace v8::internal | 1468 } } // namespace v8::internal |
| OLD | NEW |