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 5034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5045 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 5045 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
5046 | 5046 |
5047 set_code(code); | 5047 set_code(code); |
5048 | 5048 |
5049 // Add/remove the function from the list of optimized functions for this | 5049 // Add/remove the function from the list of optimized functions for this |
5050 // context based on the state change. | 5050 // context based on the state change. |
5051 if (!was_optimized && is_optimized) { | 5051 if (!was_optimized && is_optimized) { |
5052 context()->native_context()->AddOptimizedFunction(this); | 5052 context()->native_context()->AddOptimizedFunction(this); |
5053 } | 5053 } |
5054 if (was_optimized && !is_optimized) { | 5054 if (was_optimized && !is_optimized) { |
| 5055 // TODO(titzer): linear in the number of optimized functions; fix! |
5055 context()->native_context()->RemoveOptimizedFunction(this); | 5056 context()->native_context()->RemoveOptimizedFunction(this); |
5056 } | 5057 } |
5057 } | 5058 } |
5058 | 5059 |
5059 | 5060 |
5060 Context* JSFunction::context() { | 5061 Context* JSFunction::context() { |
5061 return Context::cast(READ_FIELD(this, kContextOffset)); | 5062 return Context::cast(READ_FIELD(this, kContextOffset)); |
5062 } | 5063 } |
5063 | 5064 |
5064 | 5065 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5307 | 5308 |
5308 | 5309 |
5309 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { | 5310 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { |
5310 ASSERT(kind() == FUNCTION); | 5311 ASSERT(kind() == FUNCTION); |
5311 WRITE_FIELD(this, kTypeFeedbackInfoOffset, value); | 5312 WRITE_FIELD(this, kTypeFeedbackInfoOffset, value); |
5312 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, | 5313 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, |
5313 value, mode); | 5314 value, mode); |
5314 } | 5315 } |
5315 | 5316 |
5316 | 5317 |
| 5318 Object* Code::next_code_link() { |
| 5319 CHECK(kind() == OPTIMIZED_FUNCTION); |
| 5320 return Object::cast(READ_FIELD(this, kTypeFeedbackInfoOffset)); |
| 5321 } |
| 5322 |
| 5323 |
| 5324 void Code::set_next_code_link(Object* value, WriteBarrierMode mode) { |
| 5325 CHECK(kind() == OPTIMIZED_FUNCTION); |
| 5326 WRITE_FIELD(this, kTypeFeedbackInfoOffset, value); |
| 5327 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, |
| 5328 value, mode); |
| 5329 } |
| 5330 |
| 5331 |
5317 int Code::stub_info() { | 5332 int Code::stub_info() { |
5318 ASSERT(kind() == COMPARE_IC || kind() == COMPARE_NIL_IC || | 5333 ASSERT(kind() == COMPARE_IC || kind() == COMPARE_NIL_IC || |
5319 kind() == BINARY_OP_IC || kind() == LOAD_IC); | 5334 kind() == BINARY_OP_IC || kind() == LOAD_IC); |
5320 Object* value = READ_FIELD(this, kTypeFeedbackInfoOffset); | 5335 Object* value = READ_FIELD(this, kTypeFeedbackInfoOffset); |
5321 return Smi::cast(value)->value(); | 5336 return Smi::cast(value)->value(); |
5322 } | 5337 } |
5323 | 5338 |
5324 | 5339 |
5325 void Code::set_stub_info(int value) { | 5340 void Code::set_stub_info(int value) { |
5326 ASSERT(kind() == COMPARE_IC || | 5341 ASSERT(kind() == COMPARE_IC || |
5327 kind() == COMPARE_NIL_IC || | 5342 kind() == COMPARE_NIL_IC || |
5328 kind() == BINARY_OP_IC || | 5343 kind() == BINARY_OP_IC || |
5329 kind() == STUB || | 5344 kind() == STUB || |
5330 kind() == LOAD_IC || | 5345 kind() == LOAD_IC || |
5331 kind() == KEYED_LOAD_IC || | 5346 kind() == KEYED_LOAD_IC || |
5332 kind() == STORE_IC || | 5347 kind() == STORE_IC || |
5333 kind() == KEYED_STORE_IC); | 5348 kind() == KEYED_STORE_IC); |
5334 WRITE_FIELD(this, kTypeFeedbackInfoOffset, Smi::FromInt(value)); | 5349 WRITE_FIELD(this, kTypeFeedbackInfoOffset, Smi::FromInt(value)); |
5335 } | 5350 } |
5336 | 5351 |
5337 | 5352 |
5338 Object* Code::code_to_deoptimize_link() { | |
5339 // Optimized code should not have type feedback. | |
5340 ASSERT(kind() == OPTIMIZED_FUNCTION); | |
5341 return READ_FIELD(this, kTypeFeedbackInfoOffset); | |
5342 } | |
5343 | |
5344 | |
5345 void Code::set_code_to_deoptimize_link(Object* value) { | |
5346 ASSERT(kind() == OPTIMIZED_FUNCTION); | |
5347 WRITE_FIELD(this, kTypeFeedbackInfoOffset, value); | |
5348 } | |
5349 | |
5350 | |
5351 Object** Code::code_to_deoptimize_link_slot() { | |
5352 ASSERT(kind() == OPTIMIZED_FUNCTION); | |
5353 return HeapObject::RawField(this, kTypeFeedbackInfoOffset); | |
5354 } | |
5355 | |
5356 | |
5357 ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset) | 5353 ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset) |
5358 INT_ACCESSORS(Code, ic_age, kICAgeOffset) | 5354 INT_ACCESSORS(Code, ic_age, kICAgeOffset) |
5359 | 5355 |
5360 | 5356 |
5361 byte* Code::instruction_start() { | 5357 byte* Code::instruction_start() { |
5362 return FIELD_ADDR(this, kHeaderSize); | 5358 return FIELD_ADDR(this, kHeaderSize); |
5363 } | 5359 } |
5364 | 5360 |
5365 | 5361 |
5366 byte* Code::instruction_end() { | 5362 byte* Code::instruction_end() { |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6333 #undef WRITE_UINT32_FIELD | 6329 #undef WRITE_UINT32_FIELD |
6334 #undef READ_SHORT_FIELD | 6330 #undef READ_SHORT_FIELD |
6335 #undef WRITE_SHORT_FIELD | 6331 #undef WRITE_SHORT_FIELD |
6336 #undef READ_BYTE_FIELD | 6332 #undef READ_BYTE_FIELD |
6337 #undef WRITE_BYTE_FIELD | 6333 #undef WRITE_BYTE_FIELD |
6338 | 6334 |
6339 | 6335 |
6340 } } // namespace v8::internal | 6336 } } // namespace v8::internal |
6341 | 6337 |
6342 #endif // V8_OBJECTS_INL_H_ | 6338 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |