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

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

Issue 2649873002: Split some SharedFunctionInfo's compiler hints off into debugger hints. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « src/objects.h ('k') | src/objects-printer.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 5956 matching lines...) Expand 10 before | Expand all | Expand 10 after
5967 kOriginOptionsShift); 5967 kOriginOptionsShift);
5968 } 5968 }
5969 void Script::set_origin_options(ScriptOriginOptions origin_options) { 5969 void Script::set_origin_options(ScriptOriginOptions origin_options) {
5970 DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1))); 5970 DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
5971 set_flags((flags() & ~kOriginOptionsMask) | 5971 set_flags((flags() & ~kOriginOptionsMask) |
5972 (origin_options.Flags() << kOriginOptionsShift)); 5972 (origin_options.Flags() << kOriginOptionsShift));
5973 } 5973 }
5974 5974
5975 5975
5976 ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex) 5976 ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex)
5977 SMI_ACCESSORS(DebugInfo, debugger_hints, kDebuggerHintsIndex)
5977 ACCESSORS(DebugInfo, debug_bytecode_array, Object, kDebugBytecodeArrayIndex) 5978 ACCESSORS(DebugInfo, debug_bytecode_array, Object, kDebugBytecodeArrayIndex)
5978 ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateIndex) 5979 ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateIndex)
5979 5980
5980 bool DebugInfo::HasDebugBytecodeArray() { 5981 bool DebugInfo::HasDebugBytecodeArray() {
5981 return debug_bytecode_array()->IsBytecodeArray(); 5982 return debug_bytecode_array()->IsBytecodeArray();
5982 } 5983 }
5983 5984
5984 bool DebugInfo::HasDebugCode() { 5985 bool DebugInfo::HasDebugCode() {
5985 Code* code = shared()->code(); 5986 Code* code = shared()->code();
5986 bool has = code->kind() == Code::FUNCTION; 5987 bool has = code->kind() == Code::FUNCTION;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6036 kRemovePrototypeBit) 6037 kRemovePrototypeBit)
6037 BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache, 6038 BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache,
6038 kDoNotCacheBit) 6039 kDoNotCacheBit)
6039 BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver, 6040 BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver,
6040 kAcceptAnyReceiver) 6041 kAcceptAnyReceiver)
6041 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_named_expression, 6042 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_named_expression,
6042 kIsNamedExpressionBit) 6043 kIsNamedExpressionBit)
6043 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, 6044 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
6044 kIsTopLevelBit) 6045 kIsTopLevelBit)
6045 6046
6046 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation,
6047 kAllowLazyCompilation)
6048 BOOL_ACCESSORS(SharedFunctionInfo,
6049 compiler_hints,
6050 uses_arguments,
6051 kUsesArguments)
6052 BOOL_ACCESSORS(SharedFunctionInfo,
6053 compiler_hints,
6054 has_duplicate_parameters,
6055 kHasDuplicateParameters)
6056 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, asm_function, kIsAsmFunction)
6057 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, deserialized, kDeserialized)
6058 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_declaration,
6059 kIsDeclaration)
6060 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, marked_for_tier_up,
6061 kMarkedForTierUp)
6062
6063 #if V8_HOST_ARCH_32_BIT 6047 #if V8_HOST_ARCH_32_BIT
6064 SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset) 6048 SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
6065 SMI_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count, 6049 SMI_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count,
6066 kFormalParameterCountOffset) 6050 kFormalParameterCountOffset)
6067 SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties, 6051 SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
6068 kExpectedNofPropertiesOffset) 6052 kExpectedNofPropertiesOffset)
6069 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset) 6053 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset)
6070 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type, 6054 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type,
6071 kStartPositionAndTypeOffset) 6055 kStartPositionAndTypeOffset)
6072 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset) 6056 SMI_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6137 6121
6138 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, 6122 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo,
6139 ast_node_count, 6123 ast_node_count,
6140 kAstNodeCountOffset) 6124 kAstNodeCountOffset)
6141 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, 6125 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
6142 profiler_ticks, 6126 profiler_ticks,
6143 kProfilerTicksOffset) 6127 kProfilerTicksOffset)
6144 6128
6145 #endif 6129 #endif
6146 6130
6147
6148 BOOL_GETTER(SharedFunctionInfo,
6149 compiler_hints,
6150 optimization_disabled,
6151 kOptimizationDisabled)
6152
6153 AbstractCode* SharedFunctionInfo::abstract_code() { 6131 AbstractCode* SharedFunctionInfo::abstract_code() {
6154 if (HasBytecodeArray()) { 6132 if (HasBytecodeArray()) {
6155 return AbstractCode::cast(bytecode_array()); 6133 return AbstractCode::cast(bytecode_array());
6156 } else { 6134 } else {
6157 return AbstractCode::cast(code()); 6135 return AbstractCode::cast(code());
6158 } 6136 }
6159 } 6137 }
6160 6138
6139 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation,
6140 kAllowLazyCompilation)
6141 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_arguments,
6142 kUsesArguments)
6143 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, has_duplicate_parameters,
6144 kHasDuplicateParameters)
6145 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, asm_function, kIsAsmFunction)
6146 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_declaration,
6147 kIsDeclaration)
6148 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, marked_for_tier_up,
6149 kMarkedForTierUp)
6150
6151 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object,
6152 kNeedsHomeObject)
6153 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
6154 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline)
6155 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, must_use_ignition_turbo,
6156 kMustUseIgnitionTurbo)
6157 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
6158 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_asm_wasm_broken,
6159 kIsAsmWasmBroken)
6160
6161 BOOL_GETTER(SharedFunctionInfo, compiler_hints, optimization_disabled,
6162 kOptimizationDisabled)
6163
6161 void SharedFunctionInfo::set_optimization_disabled(bool disable) { 6164 void SharedFunctionInfo::set_optimization_disabled(bool disable) {
6162 set_compiler_hints(BooleanBit::set(compiler_hints(), 6165 set_compiler_hints(BooleanBit::set(compiler_hints(),
6163 kOptimizationDisabled, 6166 kOptimizationDisabled,
6164 disable)); 6167 disable));
6165 } 6168 }
6166 6169
6167
6168 LanguageMode SharedFunctionInfo::language_mode() { 6170 LanguageMode SharedFunctionInfo::language_mode() {
6169 STATIC_ASSERT(LANGUAGE_END == 2); 6171 STATIC_ASSERT(LANGUAGE_END == 2);
6170 return construct_language_mode( 6172 return construct_language_mode(
6171 BooleanBit::get(compiler_hints(), kStrictModeFunction)); 6173 BooleanBit::get(compiler_hints(), kStrictModeFunction));
6172 } 6174 }
6173 6175
6174
6175 void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) { 6176 void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
6176 STATIC_ASSERT(LANGUAGE_END == 2); 6177 STATIC_ASSERT(LANGUAGE_END == 2);
6177 // We only allow language mode transitions that set the same language mode 6178 // We only allow language mode transitions that set the same language mode
6178 // again or go up in the chain: 6179 // again or go up in the chain:
6179 DCHECK(is_sloppy(this->language_mode()) || is_strict(language_mode)); 6180 DCHECK(is_sloppy(this->language_mode()) || is_strict(language_mode));
6180 int hints = compiler_hints(); 6181 int hints = compiler_hints();
6181 hints = BooleanBit::set(hints, kStrictModeFunction, is_strict(language_mode)); 6182 hints = BooleanBit::set(hints, kStrictModeFunction, is_strict(language_mode));
6182 set_compiler_hints(hints); 6183 set_compiler_hints(hints);
6183 } 6184 }
6184 6185
6185 FunctionKind SharedFunctionInfo::kind() const { 6186 FunctionKind SharedFunctionInfo::kind() const {
6186 return FunctionKindBits::decode(compiler_hints()); 6187 return FunctionKindBits::decode(compiler_hints());
6187 } 6188 }
6188 6189
6189
6190 void SharedFunctionInfo::set_kind(FunctionKind kind) { 6190 void SharedFunctionInfo::set_kind(FunctionKind kind) {
6191 DCHECK(IsValidFunctionKind(kind)); 6191 DCHECK(IsValidFunctionKind(kind));
6192 int hints = compiler_hints(); 6192 int hints = compiler_hints();
6193 hints = FunctionKindBits::update(hints, kind); 6193 hints = FunctionKindBits::update(hints, kind);
6194 set_compiler_hints(hints); 6194 set_compiler_hints(hints);
6195 } 6195 }
6196 6196
6197 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object, 6197 BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints,
6198 kNeedsHomeObject) 6198 name_should_print_as_anonymous, kNameShouldPrintAsAnonymous)
6199 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) 6199 BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, is_anonymous_expression,
6200 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline)
6201 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
6202 name_should_print_as_anonymous,
6203 kNameShouldPrintAsAnonymous)
6204 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous_expression,
6205 kIsAnonymousExpression) 6200 kIsAnonymousExpression)
6206 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, must_use_ignition_turbo, 6201 BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, deserialized, kDeserialized)
6207 kMustUseIgnitionTurbo) 6202 BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, has_no_side_effect,
6208 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
6209 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_asm_wasm_broken,
6210 kIsAsmWasmBroken)
6211 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, has_no_side_effect,
6212 kHasNoSideEffect) 6203 kHasNoSideEffect)
6213 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, computed_has_no_side_effect, 6204 BOOL_ACCESSORS(SharedFunctionInfo, debugger_hints, computed_has_no_side_effect,
6214 kComputedHasNoSideEffect) 6205 kComputedHasNoSideEffect)
6215 6206
6216 bool Script::HasValidSource() { 6207 bool Script::HasValidSource() {
6217 Object* src = this->source(); 6208 Object* src = this->source();
6218 if (!src->IsString()) return true; 6209 if (!src->IsString()) return true;
6219 String* src_str = String::cast(src); 6210 String* src_str = String::cast(src);
6220 if (!StringShape(src_str).IsExternal()) return true; 6211 if (!StringShape(src_str).IsExternal()) return true;
6221 if (src_str->IsOneByteRepresentation()) { 6212 if (src_str->IsOneByteRepresentation()) {
6222 return ExternalOneByteString::cast(src)->resource() != NULL; 6213 return ExternalOneByteString::cast(src)->resource() != NULL;
6223 } else if (src_str->IsTwoByteRepresentation()) { 6214 } else if (src_str->IsTwoByteRepresentation()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6308 DCHECK(code() != builtins->builtin(Builtins::kCompileOptimized)); 6299 DCHECK(code() != builtins->builtin(Builtins::kCompileOptimized));
6309 DCHECK(code() != builtins->builtin(Builtins::kCompileBaseline)); 6300 DCHECK(code() != builtins->builtin(Builtins::kCompileBaseline));
6310 return code() != builtins->builtin(Builtins::kCompileLazy); 6301 return code() != builtins->builtin(Builtins::kCompileLazy);
6311 } 6302 }
6312 6303
6313 6304
6314 bool SharedFunctionInfo::has_simple_parameters() { 6305 bool SharedFunctionInfo::has_simple_parameters() {
6315 return scope_info()->HasSimpleParameters(); 6306 return scope_info()->HasSimpleParameters();
6316 } 6307 }
6317 6308
6318 6309 bool SharedFunctionInfo::HasDebugInfo() const {
6319 bool SharedFunctionInfo::HasDebugInfo() { 6310 bool has_debug_info = !debug_info()->IsSmi();
6320 bool has_debug_info = debug_info()->IsStruct(); 6311 DCHECK_EQ(debug_info()->IsStruct(), has_debug_info);
6321 DCHECK(!has_debug_info || HasDebugCode()); 6312 DCHECK(!has_debug_info || HasDebugCode());
6322 return has_debug_info; 6313 return has_debug_info;
6323 } 6314 }
6324 6315
6325 6316 DebugInfo* SharedFunctionInfo::GetDebugInfo() const {
6326 DebugInfo* SharedFunctionInfo::GetDebugInfo() {
6327 DCHECK(HasDebugInfo()); 6317 DCHECK(HasDebugInfo());
6328 return DebugInfo::cast(debug_info()); 6318 return DebugInfo::cast(debug_info());
6329 } 6319 }
6330 6320
6331 6321 bool SharedFunctionInfo::HasDebugCode() const {
6332 bool SharedFunctionInfo::HasDebugCode() {
6333 if (HasBaselineCode()) return code()->has_debug_break_slots(); 6322 if (HasBaselineCode()) return code()->has_debug_break_slots();
6334 return HasBytecodeArray(); 6323 return HasBytecodeArray();
6335 } 6324 }
6336 6325
6326 int SharedFunctionInfo::debugger_hints() const {
6327 if (HasDebugInfo()) return GetDebugInfo()->debugger_hints();
6328 return Smi::cast(debug_info())->value();
6329 }
6330
6331 void SharedFunctionInfo::set_debugger_hints(int value) {
6332 if (HasDebugInfo()) {
6333 GetDebugInfo()->set_debugger_hints(value);
6334 } else {
6335 set_debug_info(Smi::FromInt(value));
6336 }
6337 }
6337 6338
6338 bool SharedFunctionInfo::IsApiFunction() { 6339 bool SharedFunctionInfo::IsApiFunction() {
6339 return function_data()->IsFunctionTemplateInfo(); 6340 return function_data()->IsFunctionTemplateInfo();
6340 } 6341 }
6341 6342
6342 6343
6343 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() { 6344 FunctionTemplateInfo* SharedFunctionInfo::get_api_func_data() {
6344 DCHECK(IsApiFunction()); 6345 DCHECK(IsApiFunction());
6345 return FunctionTemplateInfo::cast(function_data()); 6346 return FunctionTemplateInfo::cast(function_data());
6346 } 6347 }
6347 6348
6348 void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) { 6349 void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) {
6349 DCHECK(function_data()->IsUndefined(GetIsolate())); 6350 DCHECK(function_data()->IsUndefined(GetIsolate()));
6350 set_function_data(data); 6351 set_function_data(data);
6351 } 6352 }
6352 6353
6353 bool SharedFunctionInfo::HasBytecodeArray() { 6354 bool SharedFunctionInfo::HasBytecodeArray() const {
6354 return function_data()->IsBytecodeArray(); 6355 return function_data()->IsBytecodeArray();
6355 } 6356 }
6356 6357
6357 BytecodeArray* SharedFunctionInfo::bytecode_array() { 6358 BytecodeArray* SharedFunctionInfo::bytecode_array() const {
6358 DCHECK(HasBytecodeArray()); 6359 DCHECK(HasBytecodeArray());
6359 return BytecodeArray::cast(function_data()); 6360 return BytecodeArray::cast(function_data());
6360 } 6361 }
6361 6362
6362 void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) { 6363 void SharedFunctionInfo::set_bytecode_array(BytecodeArray* bytecode) {
6363 DCHECK(function_data()->IsUndefined(GetIsolate())); 6364 DCHECK(function_data()->IsUndefined(GetIsolate()));
6364 set_function_data(bytecode); 6365 set_function_data(bytecode);
6365 } 6366 }
6366 6367
6367 void SharedFunctionInfo::ClearBytecodeArray() { 6368 void SharedFunctionInfo::ClearBytecodeArray() {
6368 DCHECK(function_data()->IsUndefined(GetIsolate()) || HasBytecodeArray()); 6369 DCHECK(function_data()->IsUndefined(GetIsolate()) || HasBytecodeArray());
6369 set_function_data(GetHeap()->undefined_value()); 6370 set_function_data(GetHeap()->undefined_value());
6370 } 6371 }
6371 6372
6372 bool SharedFunctionInfo::HasAsmWasmData() { 6373 bool SharedFunctionInfo::HasAsmWasmData() const {
6373 return function_data()->IsFixedArray(); 6374 return function_data()->IsFixedArray();
6374 } 6375 }
6375 6376
6376 FixedArray* SharedFunctionInfo::asm_wasm_data() { 6377 FixedArray* SharedFunctionInfo::asm_wasm_data() const {
6377 DCHECK(HasAsmWasmData()); 6378 DCHECK(HasAsmWasmData());
6378 return FixedArray::cast(function_data()); 6379 return FixedArray::cast(function_data());
6379 } 6380 }
6380 6381
6381 void SharedFunctionInfo::set_asm_wasm_data(FixedArray* data) { 6382 void SharedFunctionInfo::set_asm_wasm_data(FixedArray* data) {
6382 DCHECK(function_data()->IsUndefined(GetIsolate()) || HasAsmWasmData()); 6383 DCHECK(function_data()->IsUndefined(GetIsolate()) || HasAsmWasmData());
6383 set_function_data(data); 6384 set_function_data(data);
6384 } 6385 }
6385 6386
6386 void SharedFunctionInfo::ClearAsmWasmData() { 6387 void SharedFunctionInfo::ClearAsmWasmData() {
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
8417 #undef WRITE_INT64_FIELD 8418 #undef WRITE_INT64_FIELD
8418 #undef READ_BYTE_FIELD 8419 #undef READ_BYTE_FIELD
8419 #undef WRITE_BYTE_FIELD 8420 #undef WRITE_BYTE_FIELD
8420 #undef NOBARRIER_READ_BYTE_FIELD 8421 #undef NOBARRIER_READ_BYTE_FIELD
8421 #undef NOBARRIER_WRITE_BYTE_FIELD 8422 #undef NOBARRIER_WRITE_BYTE_FIELD
8422 8423
8423 } // namespace internal 8424 } // namespace internal
8424 } // namespace v8 8425 } // namespace v8
8425 8426
8426 #endif // V8_OBJECTS_INL_H_ 8427 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698