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

Side by Side Diff: src/objects.cc

Issue 25486002: Allow code to be cached in shared maps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 4431 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 for (int i = 0; i != entries; i++) { 4442 for (int i = 0; i != entries; i++) {
4443 set_undefined(i); 4443 set_undefined(i);
4444 } 4444 }
4445 } 4445 }
4446 4446
4447 4447
4448 void HeapObject::UpdateMapCodeCache(Handle<HeapObject> object, 4448 void HeapObject::UpdateMapCodeCache(Handle<HeapObject> object,
4449 Handle<Name> name, 4449 Handle<Name> name,
4450 Handle<Code> code) { 4450 Handle<Code> code) {
4451 Handle<Map> map(object->map()); 4451 Handle<Map> map(object->map());
4452 if (map->is_shared()) {
4453 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
4454 // Fast case maps are never marked as shared.
4455 ASSERT(!receiver->HasFastProperties());
4456 // Replace the map with an identical copy that can be safely modified.
4457 map = Map::CopyNormalized(map, KEEP_INOBJECT_PROPERTIES,
4458 UNIQUE_NORMALIZED_MAP);
4459 receiver->GetIsolate()->counters()->normalized_maps()->Increment();
4460 receiver->set_map(*map);
4461 }
4462 Map::UpdateCodeCache(map, name, code); 4452 Map::UpdateCodeCache(map, name, code);
4463 } 4453 }
4464 4454
4465 4455
4466 void JSObject::NormalizeProperties(Handle<JSObject> object, 4456 void JSObject::NormalizeProperties(Handle<JSObject> object,
4467 PropertyNormalizationMode mode, 4457 PropertyNormalizationMode mode,
4468 int expected_additional_properties) { 4458 int expected_additional_properties) {
4469 if (!object->HasFastProperties()) return; 4459 if (!object->HasFastProperties()) return;
4470 4460
4471 // The global object is always normalized. 4461 // The global object is always normalized.
(...skipping 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after
7016 void Map::UpdateCodeCache(Handle<Map> map, 7006 void Map::UpdateCodeCache(Handle<Map> map,
7017 Handle<Name> name, 7007 Handle<Name> name,
7018 Handle<Code> code) { 7008 Handle<Code> code) {
7019 Isolate* isolate = map->GetIsolate(); 7009 Isolate* isolate = map->GetIsolate();
7020 CALL_HEAP_FUNCTION_VOID(isolate, 7010 CALL_HEAP_FUNCTION_VOID(isolate,
7021 map->UpdateCodeCache(*name, *code)); 7011 map->UpdateCodeCache(*name, *code));
7022 } 7012 }
7023 7013
7024 7014
7025 MaybeObject* Map::UpdateCodeCache(Name* name, Code* code) { 7015 MaybeObject* Map::UpdateCodeCache(Name* name, Code* code) {
7026 ASSERT(!is_shared() || code->allowed_in_shared_map_code_cache());
7027
7028 // Allocate the code cache if not present. 7016 // Allocate the code cache if not present.
7029 if (code_cache()->IsFixedArray()) { 7017 if (code_cache()->IsFixedArray()) {
7030 Object* result; 7018 Object* result;
7031 { MaybeObject* maybe_result = GetHeap()->AllocateCodeCache(); 7019 { MaybeObject* maybe_result = GetHeap()->AllocateCodeCache();
7032 if (!maybe_result->ToObject(&result)) return maybe_result; 7020 if (!maybe_result->ToObject(&result)) return maybe_result;
7033 } 7021 }
7034 set_code_cache(result); 7022 set_code_cache(result);
7035 } 7023 }
7036 7024
7037 // Update the code cache. 7025 // Update the code cache.
(...skipping 3421 matching lines...) Expand 10 before | Expand all | Expand 10 after
10459 DisallowHeapAllocation no_gc; 10447 DisallowHeapAllocation no_gc;
10460 ASSERT(kind() == FUNCTION); 10448 ASSERT(kind() == FUNCTION);
10461 BackEdgeTable back_edges(this, &no_gc); 10449 BackEdgeTable back_edges(this, &no_gc);
10462 for (uint32_t i = 0; i < back_edges.length(); i++) { 10450 for (uint32_t i = 0; i < back_edges.length(); i++) {
10463 if (back_edges.pc_offset(i) == pc_offset) return back_edges.ast_id(i); 10451 if (back_edges.pc_offset(i) == pc_offset) return back_edges.ast_id(i);
10464 } 10452 }
10465 return BailoutId::None(); 10453 return BailoutId::None();
10466 } 10454 }
10467 10455
10468 10456
10469 bool Code::allowed_in_shared_map_code_cache() {
10470 return is_keyed_load_stub() || is_keyed_store_stub() ||
10471 (is_compare_ic_stub() &&
10472 ICCompareStub::CompareState(stub_info()) == CompareIC::KNOWN_OBJECT);
10473 }
10474
10475
10476 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { 10457 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) {
10477 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY); 10458 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY);
10478 } 10459 }
10479 10460
10480 10461
10481 void Code::MakeOlder(MarkingParity current_parity) { 10462 void Code::MakeOlder(MarkingParity current_parity) {
10482 byte* sequence = FindCodeAgeSequence(); 10463 byte* sequence = FindCodeAgeSequence();
10483 if (sequence != NULL) { 10464 if (sequence != NULL) {
10484 Age age; 10465 Age age;
10485 MarkingParity code_parity; 10466 MarkingParity code_parity;
(...skipping 5702 matching lines...) Expand 10 before | Expand all | Expand 10 after
16188 #define ERROR_MESSAGES_TEXTS(C, T) T, 16169 #define ERROR_MESSAGES_TEXTS(C, T) T,
16189 static const char* error_messages_[] = { 16170 static const char* error_messages_[] = {
16190 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16171 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16191 }; 16172 };
16192 #undef ERROR_MESSAGES_TEXTS 16173 #undef ERROR_MESSAGES_TEXTS
16193 return error_messages_[reason]; 16174 return error_messages_[reason];
16194 } 16175 }
16195 16176
16196 16177
16197 } } // namespace v8::internal 16178 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698