Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 | |
| 28 #include "allocation-site-scopes.h" | |
|
Hannes Payer (out of office)
2013/10/11 12:55:44
newline
mvstanton
2013/10/11 13:41:47
Done.
| |
| 29 #define PTR(x) reinterpret_cast<void*>((x)) | |
|
Hannes Payer (out of office)
2013/10/11 12:55:44
I am not a fan of macros, can we just use the cast
mvstanton
2013/10/11 13:41:47
Done.
| |
| 30 | |
| 31 namespace v8 { | |
| 32 namespace internal { | |
| 33 | |
| 34 | |
| 35 AllocationSiteCreationScope::AllocationSiteCreationScope( | |
| 36 AllocationSiteContext* context) { | |
| 37 site_context_ = context; | |
| 38 | |
| 39 if (context->top().is_null()) { | |
| 40 // top level | |
|
Hannes Payer (out of office)
2013/10/11 12:55:44
Make a proper comment out of this comment or remov
mvstanton
2013/10/11 13:41:47
Done.
| |
| 41 context->top_ = context->isolate_->factory()->NewAllocationSite(); | |
| 42 ASSERT(!(context->top_->IsFailure())); | |
| 43 context->current_ = Handle<AllocationSite>(*(context->top()), | |
| 44 context->isolate_); | |
| 45 current_ = Handle<AllocationSite>(*(context->top()), context->isolate_); | |
| 46 if (FLAG_trace_creation_allocation_sites) { | |
| 47 PrintF("*** Creating top level AllocationSite %p\n", | |
| 48 PTR(*current_)); | |
| 49 } | |
| 50 } else if (context->activated()) { | |
| 51 ASSERT(!context->current().is_null()); | |
| 52 Handle<AllocationSite> new_site = | |
| 53 context->isolate_->factory()->NewAllocationSite(); | |
| 54 ASSERT(!new_site->IsFailure()); | |
| 55 if (FLAG_trace_creation_allocation_sites) { | |
| 56 PrintF("Creating nested site (top, current, new) (%p, %p, %p)\n", | |
| 57 PTR(*(context->top())), | |
| 58 PTR(*(context->current())), | |
| 59 PTR(*new_site)); | |
| 60 } | |
| 61 context->current()->set_nested_site(*new_site); | |
| 62 *context->current_.location() = *new_site; | |
| 63 current_ = Handle<AllocationSite>(*new_site, context->isolate_); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 | |
| 68 Handle<Object> AllocationSiteCreationScope::RecordTransitionInfo( | |
| 69 Handle<Object> transition_info) { | |
| 70 if (!transition_info.is_null() && !transition_info->IsFailure()) { | |
| 71 bool top_level = !current_.is_null() && | |
| 72 site_context_->top().is_identical_to(current_); | |
| 73 | |
| 74 if (top_level || site_context_->activated()) { | |
| 75 current_->set_transition_info(*transition_info); | |
| 76 if (FLAG_trace_creation_allocation_sites) { | |
| 77 if (top_level) { | |
| 78 PrintF("*** Setting AllocationSite %p transition_info %p\n", | |
| 79 PTR(*current_), | |
| 80 PTR(*transition_info)); | |
| 81 } else { | |
| 82 PrintF("Setting AllocationSite (%p, %p) transition_info %p\n", | |
| 83 PTR(*(site_context_->top())), | |
| 84 PTR(*current_), | |
| 85 PTR(*transition_info)); | |
| 86 } | |
| 87 } | |
| 88 } | |
| 89 } | |
| 90 return transition_info; | |
| 91 } | |
| 92 | |
| 93 | |
| 94 AllocationSiteUsageScope::AllocationSiteUsageScope( | |
| 95 AllocationSiteContext* context, | |
| 96 Handle<Object> expected_transition_info) { | |
| 97 ASSERT(!context->top().is_null()); | |
| 98 | |
| 99 // Advance current if activated | |
|
Hannes Payer (out of office)
2013/10/11 12:55:44
finish with "."
mvstanton
2013/10/11 13:41:47
Done.
| |
| 100 if (context->activated()) { | |
| 101 Object* nested_site = context->current_->nested_site(); | |
| 102 // Something is wrong if we advance to the end of the list here | |
|
Hannes Payer (out of office)
2013/10/11 12:55:44
finish with "."
mvstanton
2013/10/11 13:41:47
Done.
| |
| 103 ASSERT(nested_site->IsAllocationSite()); | |
| 104 AllocationSite* casted_site = AllocationSite::cast(nested_site); | |
| 105 *context->current_.location() = casted_site; | |
| 106 | |
| 107 // This assert ensures that we are pointing at the right sub-object | |
| 108 // in a recursive walk of a nested literal. It's the only | |
| 109 // usage of parameter expected_transition_info. | |
| 110 ASSERT(*expected_transition_info == casted_site->transition_info()); | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 | |
| 115 AllocationSiteUsageScope::AllocationSiteUsageScope( | |
| 116 AllocationSiteContext* context, | |
| 117 Handle<AllocationSite> top, | |
| 118 Handle<Object> expected_transition_info) { | |
| 119 ASSERT(context->top().is_null()); | |
| 120 context->top_ = top; | |
| 121 if (context->activated()) { | |
| 122 // We only need current_ to be a handle if we are using the field. | |
| 123 // We only use the field in the recursive case. | |
| 124 context->current_ = Handle<AllocationSite>(*top, context->isolate_); | |
| 125 } | |
| 126 | |
| 127 // This assert ensures that we are pointing at the right object | |
| 128 // in the allocation site | |
|
Hannes Payer (out of office)
2013/10/11 12:55:44
finish with "."
mvstanton
2013/10/11 13:41:47
Done.
| |
| 129 // in a recursive walk of a nested literal. It's the only | |
| 130 // usage of parameter expected_transition_info. | |
| 131 ASSERT(*expected_transition_info == top->transition_info()); | |
| 132 } | |
| 133 | |
| 134 } } // namespace v8::internal | |
| OLD | NEW |