OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 bool is_result_from_cache; | 262 bool is_result_from_cache; |
263 Handle<Map> map = ComputeObjectLiteralMap(context, | 263 Handle<Map> map = ComputeObjectLiteralMap(context, |
264 constant_properties, | 264 constant_properties, |
265 &is_result_from_cache); | 265 &is_result_from_cache); |
266 | 266 |
267 Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map); | 267 Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map); |
268 { // Add the constant properties to the boilerplate. | 268 { // Add the constant properties to the boilerplate. |
269 int length = constant_properties->length(); | 269 int length = constant_properties->length(); |
270 OptimizedObjectForAddingMultipleProperties opt(boilerplate, | 270 OptimizedObjectForAddingMultipleProperties opt(boilerplate, |
| 271 length / 2, |
271 !is_result_from_cache); | 272 !is_result_from_cache); |
272 for (int index = 0; index < length; index +=2) { | 273 for (int index = 0; index < length; index +=2) { |
273 Handle<Object> key(constant_properties->get(index+0)); | 274 Handle<Object> key(constant_properties->get(index+0)); |
274 Handle<Object> value(constant_properties->get(index+1)); | 275 Handle<Object> value(constant_properties->get(index+1)); |
275 if (value->IsFixedArray()) { | 276 if (value->IsFixedArray()) { |
276 // The value contains the constant_properties of a | 277 // The value contains the constant_properties of a |
277 // simple object literal. | 278 // simple object literal. |
278 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 279 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
279 value = CreateLiteralBoilerplate(literals, array); | 280 value = CreateLiteralBoilerplate(literals, array); |
280 if (value.is_null()) return value; | 281 if (value.is_null()) return value; |
(...skipping 2745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3026 } | 3027 } |
3027 return *object; | 3028 return *object; |
3028 } | 3029 } |
3029 | 3030 |
3030 | 3031 |
3031 static Object* Runtime_ToSlowProperties(Arguments args) { | 3032 static Object* Runtime_ToSlowProperties(Arguments args) { |
3032 ASSERT(args.length() == 1); | 3033 ASSERT(args.length() == 1); |
3033 Handle<Object> object = args.at<Object>(0); | 3034 Handle<Object> object = args.at<Object>(0); |
3034 if (object->IsJSObject()) { | 3035 if (object->IsJSObject()) { |
3035 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 3036 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
3036 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES); | 3037 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
3037 } | 3038 } |
3038 return *object; | 3039 return *object; |
3039 } | 3040 } |
3040 | 3041 |
3041 | 3042 |
3042 static Object* Runtime_ToBool(Arguments args) { | 3043 static Object* Runtime_ToBool(Arguments args) { |
3043 NoHandleAllocation ha; | 3044 NoHandleAllocation ha; |
3044 ASSERT(args.length() == 1); | 3045 ASSERT(args.length() == 1); |
3045 | 3046 |
3046 return args[0]->ToBoolean(); | 3047 return args[0]->ToBoolean(); |
(...skipping 4553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7600 } else { | 7601 } else { |
7601 // Handle last resort GC and make sure to allow future allocations | 7602 // Handle last resort GC and make sure to allow future allocations |
7602 // to grow the heap without causing GCs (if possible). | 7603 // to grow the heap without causing GCs (if possible). |
7603 Counters::gc_last_resort_from_js.Increment(); | 7604 Counters::gc_last_resort_from_js.Increment(); |
7604 Heap::CollectAllGarbage(); | 7605 Heap::CollectAllGarbage(); |
7605 } | 7606 } |
7606 } | 7607 } |
7607 | 7608 |
7608 | 7609 |
7609 } } // namespace v8::internal | 7610 } } // namespace v8::internal |
OLD | NEW |