Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: src/objects.cc

Issue 6793013: Cache optimized code on shared function info. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 6130 matching lines...) Expand 10 before | Expand all | Expand 10 after
6141 if (slack != 0) { 6141 if (slack != 0) {
6142 // Resize the initial map and all maps in its transition tree. 6142 // Resize the initial map and all maps in its transition tree.
6143 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); 6143 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack);
6144 // Give the correct expected_nof_properties to initial maps created later. 6144 // Give the correct expected_nof_properties to initial maps created later.
6145 ASSERT(expected_nof_properties() >= slack); 6145 ASSERT(expected_nof_properties() >= slack);
6146 set_expected_nof_properties(expected_nof_properties() - slack); 6146 set_expected_nof_properties(expected_nof_properties() - slack);
6147 } 6147 }
6148 } 6148 }
6149 6149
6150 6150
6151 Code* SharedFunctionInfo::SearchOptimizedCodeMap(Context* global_context) {
6152 ASSERT(global_context->IsGlobalContext());
6153 Object* value = optimized_code_map();
6154 if (!value->IsSmi()) {
6155 FixedArray* optimized_code_map = FixedArray::cast(value);
6156 int length = optimized_code_map->length();
6157 for (int i = 0; i < length; i += 2) {
6158 if (optimized_code_map->get(i) == global_context) {
6159 return Code::cast(optimized_code_map->get(i + 1));
6160 }
6161 }
6162 }
6163
6164 return NULL;
6165 }
6166
6167
6151 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { 6168 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
6152 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 6169 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
6153 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 6170 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
6154 Object* old_target = target; 6171 Object* old_target = target;
6155 VisitPointer(&target); 6172 VisitPointer(&target);
6156 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. 6173 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
6157 } 6174 }
6158 6175
6159 6176
6160 void ObjectVisitor::VisitCodeEntry(Address entry_address) { 6177 void ObjectVisitor::VisitCodeEntry(Address entry_address) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
6347 if (FLAG_print_code_verbose) { 6364 if (FLAG_print_code_verbose) {
6348 PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode), 6365 PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode),
6349 frame_count); 6366 frame_count);
6350 } 6367 }
6351 6368
6352 for (int i = 0; i < frame_count; ++i) { 6369 for (int i = 0; i < frame_count; ++i) {
6353 opcode = static_cast<Translation::Opcode>(iterator.Next()); 6370 opcode = static_cast<Translation::Opcode>(iterator.Next());
6354 ASSERT(Translation::FRAME == opcode); 6371 ASSERT(Translation::FRAME == opcode);
6355 int ast_id = iterator.Next(); 6372 int ast_id = iterator.Next();
6356 int function_id = iterator.Next(); 6373 int function_id = iterator.Next();
6357 JSFunction* function =
6358 JSFunction::cast(LiteralArray()->get(function_id));
6359 unsigned height = iterator.Next(); 6374 unsigned height = iterator.Next();
6360 if (FLAG_print_code_verbose) { 6375 if (FLAG_print_code_verbose) {
6361 PrintF(out, "%24s %s {ast_id=%d, function=", 6376 PrintF(out, "%24s %s {ast_id=%d, function=",
6362 "", Translation::StringFor(opcode), ast_id); 6377 "", Translation::StringFor(opcode), ast_id);
6363 function->PrintName(out); 6378 if (function_id != Translation::kSelfLiteralId) {
6379 Object* function = LiteralArray()->get(function_id);
6380 JSFunction::cast(function)->PrintName(out);
6381 } else {
6382 PrintF(out, "<self>");
6383 }
6364 PrintF(out, ", height=%u}\n", height); 6384 PrintF(out, ", height=%u}\n", height);
6365 } 6385 }
6366 6386
6367 // Size of translation is height plus all incoming arguments including 6387 while (iterator.HasNext()) {
6368 // receiver.
6369 int size = height + function->shared()->formal_parameter_count() + 1;
6370 command_count += size;
6371 for (int j = 0; j < size; ++j) {
6372 opcode = static_cast<Translation::Opcode>(iterator.Next()); 6388 opcode = static_cast<Translation::Opcode>(iterator.Next());
6389 if (opcode == Translation::FRAME
6390 || opcode == Translation::BEGIN) {
6391 iterator.Undo();
6392 break;
6393 }
6394
6395 command_count++;
6396
6373 if (FLAG_print_code_verbose) { 6397 if (FLAG_print_code_verbose) {
6374 PrintF(out, "%24s %s ", "", Translation::StringFor(opcode)); 6398 PrintF(out, "%24s %s ", "", Translation::StringFor(opcode));
6375 } 6399 }
6376 6400
6377 if (opcode == Translation::DUPLICATE) { 6401 if (opcode == Translation::DUPLICATE) {
6378 opcode = static_cast<Translation::Opcode>(iterator.Next()); 6402 opcode = static_cast<Translation::Opcode>(iterator.Next());
6379 if (FLAG_print_code_verbose) { 6403 if (FLAG_print_code_verbose) {
6380 PrintF(out, "%s ", Translation::StringFor(opcode)); 6404 PrintF(out, "%s ", Translation::StringFor(opcode));
6381 } 6405 }
6382 --j; // Two commands share the same frame index.
6383 } 6406 }
6384 6407
6385 switch (opcode) { 6408 switch (opcode) {
6386 case Translation::BEGIN: 6409 case Translation::BEGIN:
6387 case Translation::FRAME: 6410 case Translation::FRAME:
6388 case Translation::DUPLICATE: 6411 case Translation::DUPLICATE:
6389 UNREACHABLE(); 6412 UNREACHABLE();
6390 break; 6413 break;
6391 6414
6392 case Translation::REGISTER: { 6415 case Translation::REGISTER: {
(...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after
10287 if (break_point_objects()->IsUndefined()) return 0; 10310 if (break_point_objects()->IsUndefined()) return 0;
10288 // Single beak point. 10311 // Single beak point.
10289 if (!break_point_objects()->IsFixedArray()) return 1; 10312 if (!break_point_objects()->IsFixedArray()) return 1;
10290 // Multiple break points. 10313 // Multiple break points.
10291 return FixedArray::cast(break_point_objects())->length(); 10314 return FixedArray::cast(break_point_objects())->length();
10292 } 10315 }
10293 #endif 10316 #endif
10294 10317
10295 10318
10296 } } // namespace v8::internal 10319 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698