OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 return Handle<TYPE>(TYPE::cast(__object__), ISOLATE); \ | 30 return Handle<TYPE>(TYPE::cast(__object__), ISOLATE); \ |
31 } | 31 } |
32 | 32 |
33 #define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE) \ | 33 #define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE) \ |
34 do { \ | 34 do { \ |
35 AllocationResult __allocation__ = FUNCTION_CALL; \ | 35 AllocationResult __allocation__ = FUNCTION_CALL; \ |
36 Object* __object__ = NULL; \ | 36 Object* __object__ = NULL; \ |
37 RETURN_OBJECT_UNLESS_RETRY(ISOLATE, TYPE) \ | 37 RETURN_OBJECT_UNLESS_RETRY(ISOLATE, TYPE) \ |
38 /* Two GCs before panicking. In newspace will almost always succeed. */ \ | 38 /* Two GCs before panicking. In newspace will almost always succeed. */ \ |
39 for (int __i__ = 0; __i__ < 2; __i__++) { \ | 39 for (int __i__ = 0; __i__ < 2; __i__++) { \ |
40 (ISOLATE)->heap()->CollectGarbage(__allocation__.RetrySpace(), \ | 40 (ISOLATE)->heap()->CollectGarbage( \ |
41 "allocation failure"); \ | 41 __allocation__.RetrySpace(), \ |
| 42 GarbageCollectionReason::kAllocationFailure); \ |
42 __allocation__ = FUNCTION_CALL; \ | 43 __allocation__ = FUNCTION_CALL; \ |
43 RETURN_OBJECT_UNLESS_RETRY(ISOLATE, TYPE) \ | 44 RETURN_OBJECT_UNLESS_RETRY(ISOLATE, TYPE) \ |
44 } \ | 45 } \ |
45 (ISOLATE)->counters()->gc_last_resort_from_handles()->Increment(); \ | 46 (ISOLATE)->counters()->gc_last_resort_from_handles()->Increment(); \ |
46 (ISOLATE)->heap()->CollectAllAvailableGarbage("last resort gc"); \ | 47 (ISOLATE)->heap()->CollectAllAvailableGarbage( \ |
| 48 GarbageCollectionReason::kLastResort); \ |
47 { \ | 49 { \ |
48 AlwaysAllocateScope __scope__(ISOLATE); \ | 50 AlwaysAllocateScope __scope__(ISOLATE); \ |
49 __allocation__ = FUNCTION_CALL; \ | 51 __allocation__ = FUNCTION_CALL; \ |
50 } \ | 52 } \ |
51 RETURN_OBJECT_UNLESS_RETRY(ISOLATE, TYPE) \ | 53 RETURN_OBJECT_UNLESS_RETRY(ISOLATE, TYPE) \ |
52 /* TODO(1181417): Fix this. */ \ | 54 /* TODO(1181417): Fix this. */ \ |
53 v8::internal::Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); \ | 55 v8::internal::Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); \ |
54 return Handle<TYPE>(); \ | 56 return Handle<TYPE>(); \ |
55 } while (false) | 57 } while (false) |
56 | 58 |
57 | |
58 template<typename T> | 59 template<typename T> |
59 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { | 60 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { |
60 CALL_HEAP_FUNCTION( | 61 CALL_HEAP_FUNCTION( |
61 isolate(), | 62 isolate(), |
62 isolate()->heap()->Allocate(*map, space), | 63 isolate()->heap()->Allocate(*map, space), |
63 T); | 64 T); |
64 } | 65 } |
65 | 66 |
66 | 67 |
67 template<typename T> | 68 template<typename T> |
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 Handle<AccessorInfo> prototype = | 2516 Handle<AccessorInfo> prototype = |
2516 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2517 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2517 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2518 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2518 prototype, attribs); | 2519 prototype, attribs); |
2519 map->AppendDescriptor(&d); | 2520 map->AppendDescriptor(&d); |
2520 } | 2521 } |
2521 } | 2522 } |
2522 | 2523 |
2523 } // namespace internal | 2524 } // namespace internal |
2524 } // namespace v8 | 2525 } // namespace v8 |
OLD | NEW |