OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 case EXTERNAL_FLOAT_ELEMENTS: | 248 case EXTERNAL_FLOAT_ELEMENTS: |
249 case EXTERNAL_DOUBLE_ELEMENTS: | 249 case EXTERNAL_DOUBLE_ELEMENTS: |
250 case FAST_DOUBLE_ELEMENTS: | 250 case FAST_DOUBLE_ELEMENTS: |
251 // No contained objects, nothing to do. | 251 // No contained objects, nothing to do. |
252 break; | 252 break; |
253 } | 253 } |
254 return copy; | 254 return copy; |
255 } | 255 } |
256 | 256 |
257 | 257 |
258 RUNTIME_FUNCTION(MaybeObject*, Runtime_CloneLiteralBoilerplate) { | |
259 CONVERT_CHECKED(JSObject, boilerplate, args[0]); | |
260 return DeepCopyBoilerplate(isolate, boilerplate); | |
261 } | |
262 | |
263 | |
264 RUNTIME_FUNCTION(MaybeObject*, Runtime_CloneShallowLiteralBoilerplate) { | |
265 CONVERT_CHECKED(JSObject, boilerplate, args[0]); | |
266 return isolate->heap()->CopyJSObject(boilerplate); | |
267 } | |
268 | |
269 | |
270 static Handle<Map> ComputeObjectLiteralMap( | 258 static Handle<Map> ComputeObjectLiteralMap( |
271 Handle<Context> context, | 259 Handle<Context> context, |
272 Handle<FixedArray> constant_properties, | 260 Handle<FixedArray> constant_properties, |
273 bool* is_result_from_cache) { | 261 bool* is_result_from_cache) { |
274 Isolate* isolate = context->GetIsolate(); | 262 Isolate* isolate = context->GetIsolate(); |
275 int properties_length = constant_properties->length(); | 263 int properties_length = constant_properties->length(); |
276 int number_of_properties = properties_length / 2; | 264 int number_of_properties = properties_length / 2; |
277 if (FLAG_canonicalize_object_literal_maps) { | 265 if (FLAG_canonicalize_object_literal_maps) { |
278 // Check that there are only symbols and array indices among keys. | 266 // Check that there are only symbols and array indices among keys. |
279 int number_of_symbol_keys = 0; | 267 int number_of_symbol_keys = 0; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 kHasNoFunctionLiteral); | 526 kHasNoFunctionLiteral); |
539 case CompileTimeValue::ARRAY_LITERAL: | 527 case CompileTimeValue::ARRAY_LITERAL: |
540 return CreateArrayLiteralBoilerplate(isolate, literals, elements); | 528 return CreateArrayLiteralBoilerplate(isolate, literals, elements); |
541 default: | 529 default: |
542 UNREACHABLE(); | 530 UNREACHABLE(); |
543 return Handle<Object>::null(); | 531 return Handle<Object>::null(); |
544 } | 532 } |
545 } | 533 } |
546 | 534 |
547 | 535 |
548 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralBoilerplate) { | |
549 // Takes a FixedArray of elements containing the literal elements of | |
550 // the array literal and produces JSArray with those elements. | |
551 // Additionally takes the literals array of the surrounding function | |
552 // which contains the context from which to get the Array function | |
553 // to use for creating the array literal. | |
554 HandleScope scope(isolate); | |
555 ASSERT(args.length() == 3); | |
556 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | |
557 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | |
558 CONVERT_ARG_CHECKED(FixedArray, elements, 2); | |
559 | |
560 Handle<Object> object = | |
561 CreateArrayLiteralBoilerplate(isolate, literals, elements); | |
562 if (object.is_null()) return Failure::Exception(); | |
563 | |
564 // Update the functions literal and return the boilerplate. | |
565 literals->set(literals_index, *object); | |
566 return *object; | |
567 } | |
568 | |
569 | |
570 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { | 536 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { |
571 HandleScope scope(isolate); | 537 HandleScope scope(isolate); |
572 ASSERT(args.length() == 4); | 538 ASSERT(args.length() == 4); |
573 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 539 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
574 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 540 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
575 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); | 541 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); |
576 CONVERT_SMI_ARG_CHECKED(flags, 3); | 542 CONVERT_SMI_ARG_CHECKED(flags, 3); |
577 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 543 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
578 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 544 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
579 | 545 |
(...skipping 12893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13473 } else { | 13439 } else { |
13474 // Handle last resort GC and make sure to allow future allocations | 13440 // Handle last resort GC and make sure to allow future allocations |
13475 // to grow the heap without causing GCs (if possible). | 13441 // to grow the heap without causing GCs (if possible). |
13476 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13442 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13477 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13443 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13478 } | 13444 } |
13479 } | 13445 } |
13480 | 13446 |
13481 | 13447 |
13482 } } // namespace v8::internal | 13448 } } // namespace v8::internal |
OLD | NEW |