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 10340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10351 static_cast<uint32_t>(elements->length()); | 10351 static_cast<uint32_t>(elements->length()); |
10352 uint32_t min_length = actual_length < length ? actual_length : length; | 10352 uint32_t min_length = actual_length < length ? actual_length : length; |
10353 Handle<Object> length_object = | 10353 Handle<Object> length_object = |
10354 isolate->factory()->NewNumber(static_cast<double>(min_length)); | 10354 isolate->factory()->NewNumber(static_cast<double>(min_length)); |
10355 single_interval->set(1, *length_object); | 10355 single_interval->set(1, *length_object); |
10356 return *isolate->factory()->NewJSArrayWithElements(single_interval); | 10356 return *isolate->factory()->NewJSArrayWithElements(single_interval); |
10357 } | 10357 } |
10358 } | 10358 } |
10359 | 10359 |
10360 | 10360 |
10361 // DefineAccessor takes an optional final argument which is the | |
10362 // property attributes (e.g. DONT_ENUM, DONT_DELETE). IMPORTANT: due | |
10363 // to the way accessors are implemented, it is set for both the getter | |
10364 // and setter on the first call to DefineAccessor and ignored on | |
10365 // subsequent calls. | |
10366 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineAccessor) { | |
10367 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | |
10368 // Compute attributes. | |
10369 PropertyAttributes attributes = NONE; | |
10370 if (args.length() == 5) { | |
10371 CONVERT_CHECKED(Smi, attrs, args[4]); | |
10372 int value = attrs->value(); | |
10373 // Only attribute bits should be set. | |
10374 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | |
10375 attributes = static_cast<PropertyAttributes>(value); | |
10376 } | |
10377 | |
10378 CONVERT_CHECKED(JSObject, obj, args[0]); | |
10379 CONVERT_CHECKED(String, name, args[1]); | |
10380 CONVERT_CHECKED(Smi, flag, args[2]); | |
10381 CONVERT_CHECKED(JSFunction, fun, args[3]); | |
10382 return obj->DefineAccessor(name, flag->value() == 0, fun, attributes); | |
10383 } | |
10384 | |
10385 | |
10386 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { | 10361 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { |
10387 ASSERT(args.length() == 3); | 10362 ASSERT(args.length() == 3); |
10388 CONVERT_CHECKED(JSObject, obj, args[0]); | 10363 CONVERT_CHECKED(JSObject, obj, args[0]); |
10389 CONVERT_CHECKED(String, name, args[1]); | 10364 CONVERT_CHECKED(String, name, args[1]); |
10390 CONVERT_CHECKED(Smi, flag, args[2]); | 10365 CONVERT_CHECKED(Smi, flag, args[2]); |
10391 return obj->LookupAccessor(name, flag->value() == 0); | 10366 return obj->LookupAccessor(name, flag->value() == 0); |
10392 } | 10367 } |
10393 | 10368 |
10394 | 10369 |
10395 #ifdef ENABLE_DEBUGGER_SUPPORT | 10370 #ifdef ENABLE_DEBUGGER_SUPPORT |
(...skipping 3276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13672 // Handle last resort GC and make sure to allow future allocations | 13647 // Handle last resort GC and make sure to allow future allocations |
13673 // to grow the heap without causing GCs (if possible). | 13648 // to grow the heap without causing GCs (if possible). |
13674 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13649 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13675 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13650 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13676 "Runtime::PerformGC"); | 13651 "Runtime::PerformGC"); |
13677 } | 13652 } |
13678 } | 13653 } |
13679 | 13654 |
13680 | 13655 |
13681 } } // namespace v8::internal | 13656 } } // namespace v8::internal |
OLD | NEW |