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 7561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7572 } | 7572 } |
7573 | 7573 |
7574 | 7574 |
7575 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, | 7575 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, |
7576 ClearExceptionFlag flag) { | 7576 ClearExceptionFlag flag) { |
7577 CompilationInfo info(shared); | 7577 CompilationInfo info(shared); |
7578 return CompileLazyHelper(&info, flag); | 7578 return CompileLazyHelper(&info, flag); |
7579 } | 7579 } |
7580 | 7580 |
7581 | 7581 |
7582 void SharedFunctionInfo::ClearOptimizedCodeMap() { | |
7583 set_optimized_code_map(Smi::FromInt(0)); | |
Michael Starzinger
2012/06/14 13:51:32
It would simplify the runtime code if we would ini
Florian Schneider
2012/06/14 14:02:41
I'll leave it as is for now. I assume it should no
| |
7584 } | |
7585 | |
7586 | |
7587 void SharedFunctionInfo::AddToOptimizedCodeMap( | |
7588 Handle<SharedFunctionInfo> shared, | |
7589 Handle<Context> global_context, | |
7590 Handle<Code> code, | |
7591 Handle<FixedArray> literals) { | |
7592 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | |
7593 ASSERT(global_context->IsGlobalContext()); | |
7594 STATIC_ASSERT(kEntryLength == 3); | |
7595 Object* value = shared->optimized_code_map(); | |
7596 Handle<FixedArray> new_code_map; | |
7597 if (value->IsSmi()) { | |
7598 // No optimized code map. | |
7599 ASSERT_EQ(0, Smi::cast(value)->value()); | |
7600 // Crate 3 entries per context {context, code, literals}. | |
7601 new_code_map = FACTORY->NewFixedArray(kEntryLength); | |
7602 new_code_map->set(0, *global_context); | |
7603 new_code_map->set(1, *code); | |
7604 new_code_map->set(2, *literals); | |
7605 } else { | |
7606 // Copy old map and append one new entry. | |
7607 Handle<FixedArray> old_code_map(FixedArray::cast(value)); | |
7608 ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*global_context)); | |
7609 int old_length = old_code_map->length(); | |
7610 int new_length = old_length + kEntryLength; | |
7611 new_code_map = FACTORY->NewFixedArray(new_length); | |
7612 old_code_map->CopyTo(0, *new_code_map, 0, old_length); | |
7613 new_code_map->set(old_length, *global_context); | |
7614 new_code_map->set(old_length + 1, *code); | |
7615 new_code_map->set(old_length + 2, *literals); | |
7616 } | |
7617 #ifdef DEBUG | |
7618 for (int i = 0; i < new_code_map->length(); i += kEntryLength) { | |
7619 ASSERT(new_code_map->get(i)->IsGlobalContext()); | |
7620 ASSERT(new_code_map->get(i + 1)->IsCode()); | |
7621 ASSERT(Code::cast(new_code_map->get(i + 1))->kind() == | |
7622 Code::OPTIMIZED_FUNCTION); | |
7623 ASSERT(new_code_map->get(i + 2)->IsFixedArray()); | |
7624 } | |
7625 #endif | |
7626 shared->set_optimized_code_map(*new_code_map); | |
7627 } | |
7628 | |
7629 | |
7582 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7630 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
7583 ClearExceptionFlag flag) { | 7631 ClearExceptionFlag flag) { |
7584 bool result = true; | 7632 bool result = true; |
7585 if (function->shared()->is_compiled()) { | 7633 if (function->shared()->is_compiled()) { |
7586 function->ReplaceCode(function->shared()->code()); | 7634 function->ReplaceCode(function->shared()->code()); |
7587 function->shared()->set_code_age(0); | 7635 function->shared()->set_code_age(0); |
7588 } else { | 7636 } else { |
7589 CompilationInfo info(function); | 7637 CompilationInfo info(function); |
7590 result = CompileLazyHelper(&info, flag); | 7638 result = CompileLazyHelper(&info, flag); |
7591 ASSERT(!result || function->is_compiled()); | 7639 ASSERT(!result || function->is_compiled()); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8089 // Resize the initial map and all maps in its transition tree. | 8137 // Resize the initial map and all maps in its transition tree. |
8090 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); | 8138 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); |
8091 | 8139 |
8092 // Give the correct expected_nof_properties to initial maps created later. | 8140 // Give the correct expected_nof_properties to initial maps created later. |
8093 ASSERT(expected_nof_properties() >= slack); | 8141 ASSERT(expected_nof_properties() >= slack); |
8094 set_expected_nof_properties(expected_nof_properties() - slack); | 8142 set_expected_nof_properties(expected_nof_properties() - slack); |
8095 } | 8143 } |
8096 } | 8144 } |
8097 | 8145 |
8098 | 8146 |
8147 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* global_context) { | |
8148 ASSERT(global_context->IsGlobalContext()); | |
8149 Object* value = optimized_code_map(); | |
8150 if (!value->IsSmi()) { | |
8151 FixedArray* optimized_code_map = FixedArray::cast(value); | |
8152 int length = optimized_code_map->length(); | |
8153 for (int i = 0; i < length; i += 3) { | |
8154 if (optimized_code_map->get(i) == global_context) { | |
8155 return i + 1; | |
8156 } | |
8157 } | |
8158 } | |
8159 return -1; | |
8160 } | |
8161 | |
8162 | |
8099 void SharedFunctionInfo::SharedFunctionInfoIterateBody(ObjectVisitor* v) { | 8163 void SharedFunctionInfo::SharedFunctionInfoIterateBody(ObjectVisitor* v) { |
8100 v->VisitSharedFunctionInfo(this); | 8164 v->VisitSharedFunctionInfo(this); |
8101 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); | 8165 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); |
8102 } | 8166 } |
8103 | 8167 |
8104 | 8168 |
8105 #define DECLARE_TAG(ignore1, name, ignore2) name, | 8169 #define DECLARE_TAG(ignore1, name, ignore2) name, |
8106 const char* const VisitorSynchronization::kTags[ | 8170 const char* const VisitorSynchronization::kTags[ |
8107 VisitorSynchronization::kNumberOfSyncTags] = { | 8171 VisitorSynchronization::kNumberOfSyncTags] = { |
8108 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) | 8172 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8374 PrintF(out, "%24s %s ", "", Translation::StringFor(opcode)); | 8438 PrintF(out, "%24s %s ", "", Translation::StringFor(opcode)); |
8375 | 8439 |
8376 switch (opcode) { | 8440 switch (opcode) { |
8377 case Translation::BEGIN: | 8441 case Translation::BEGIN: |
8378 UNREACHABLE(); | 8442 UNREACHABLE(); |
8379 break; | 8443 break; |
8380 | 8444 |
8381 case Translation::JS_FRAME: { | 8445 case Translation::JS_FRAME: { |
8382 int ast_id = iterator.Next(); | 8446 int ast_id = iterator.Next(); |
8383 int function_id = iterator.Next(); | 8447 int function_id = iterator.Next(); |
8384 JSFunction* function = | |
8385 JSFunction::cast(LiteralArray()->get(function_id)); | |
8386 unsigned height = iterator.Next(); | 8448 unsigned height = iterator.Next(); |
8387 PrintF(out, "{ast_id=%d, function=", ast_id); | 8449 PrintF(out, "{ast_id=%d, function=", ast_id); |
8388 function->PrintName(out); | 8450 if (function_id != Translation::kSelfLiteralId) { |
8451 Object* function = LiteralArray()->get(function_id); | |
8452 JSFunction::cast(function)->PrintName(out); | |
8453 } else { | |
8454 PrintF(out, "<self>"); | |
8455 } | |
8389 PrintF(out, ", height=%u}", height); | 8456 PrintF(out, ", height=%u}", height); |
8390 break; | 8457 break; |
8391 } | 8458 } |
8392 | 8459 |
8393 case Translation::ARGUMENTS_ADAPTOR_FRAME: | 8460 case Translation::ARGUMENTS_ADAPTOR_FRAME: |
8394 case Translation::CONSTRUCT_STUB_FRAME: { | 8461 case Translation::CONSTRUCT_STUB_FRAME: { |
8395 int function_id = iterator.Next(); | 8462 int function_id = iterator.Next(); |
8396 JSFunction* function = | 8463 JSFunction* function = |
8397 JSFunction::cast(LiteralArray()->get(function_id)); | 8464 JSFunction::cast(LiteralArray()->get(function_id)); |
8398 unsigned height = iterator.Next(); | 8465 unsigned height = iterator.Next(); |
(...skipping 4764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13163 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13230 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13164 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13231 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13165 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13232 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13166 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13233 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13167 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13234 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13168 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13235 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13169 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13236 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13170 } | 13237 } |
13171 | 13238 |
13172 } } // namespace v8::internal | 13239 } } // namespace v8::internal |
OLD | NEW |