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

Side by Side Diff: src/objects-inl.h

Issue 11293059: Fix slack tracking when instance prototype changes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Daniel Clifford. Created 8 years, 1 month 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.cc ('k') | src/x64/stub-cache-x64.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 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 4395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4406 Map* JSFunction::initial_map() { 4406 Map* JSFunction::initial_map() {
4407 return Map::cast(prototype_or_initial_map()); 4407 return Map::cast(prototype_or_initial_map());
4408 } 4408 }
4409 4409
4410 4410
4411 void JSFunction::set_initial_map(Map* value) { 4411 void JSFunction::set_initial_map(Map* value) {
4412 set_prototype_or_initial_map(value); 4412 set_prototype_or_initial_map(value);
4413 } 4413 }
4414 4414
4415 4415
4416 MaybeObject* JSFunction::set_initial_map_and_cache_transitions(
4417 Map* initial_map) {
4418 Context* native_context = context()->native_context();
4419 Object* array_function =
4420 native_context->get(Context::ARRAY_FUNCTION_INDEX);
4421 if (array_function->IsJSFunction() &&
4422 this == JSFunction::cast(array_function)) {
4423 // Replace all of the cached initial array maps in the native context with
4424 // the appropriate transitioned elements kind maps.
4425 Heap* heap = GetHeap();
4426 MaybeObject* maybe_maps =
4427 heap->AllocateFixedArrayWithHoles(kElementsKindCount);
4428 FixedArray* maps;
4429 if (!maybe_maps->To(&maps)) return maybe_maps;
4430
4431 Map* current_map = initial_map;
4432 ElementsKind kind = current_map->elements_kind();
4433 ASSERT(kind == GetInitialFastElementsKind());
4434 maps->set(kind, current_map);
4435 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1;
4436 i < kFastElementsKindCount; ++i) {
4437 Map* new_map;
4438 ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i);
4439 MaybeObject* maybe_new_map =
4440 current_map->CopyAsElementsKind(next_kind, INSERT_TRANSITION);
4441 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
4442 maps->set(next_kind, new_map);
4443 current_map = new_map;
4444 }
4445 native_context->set_js_array_maps(maps);
4446 }
4447 set_initial_map(initial_map);
4448 return this;
4449 }
4450
4451
4452 bool JSFunction::has_initial_map() { 4416 bool JSFunction::has_initial_map() {
4453 return prototype_or_initial_map()->IsMap(); 4417 return prototype_or_initial_map()->IsMap();
4454 } 4418 }
4455 4419
4456 4420
4457 bool JSFunction::has_instance_prototype() { 4421 bool JSFunction::has_instance_prototype() {
4458 return has_initial_map() || !prototype_or_initial_map()->IsTheHole(); 4422 return has_initial_map() || !prototype_or_initial_map()->IsTheHole();
4459 } 4423 }
4460 4424
4461 4425
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
5541 #undef WRITE_UINT32_FIELD 5505 #undef WRITE_UINT32_FIELD
5542 #undef READ_SHORT_FIELD 5506 #undef READ_SHORT_FIELD
5543 #undef WRITE_SHORT_FIELD 5507 #undef WRITE_SHORT_FIELD
5544 #undef READ_BYTE_FIELD 5508 #undef READ_BYTE_FIELD
5545 #undef WRITE_BYTE_FIELD 5509 #undef WRITE_BYTE_FIELD
5546 5510
5547 5511
5548 } } // namespace v8::internal 5512 } } // namespace v8::internal
5549 5513
5550 #endif // V8_OBJECTS_INL_H_ 5514 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698