| OLD | NEW |
| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/cpu-profiler.h" | 9 #include "src/cpu-profiler.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| 11 #include "src/gdb-jit.h" | 11 #include "src/gdb-jit.h" |
| 12 #include "src/ic/handler-compiler.h" | 12 #include "src/ic/handler-compiler.h" |
| 13 #include "src/ic/ic.h" |
| 13 #include "src/macro-assembler.h" | 14 #include "src/macro-assembler.h" |
| 14 | 15 |
| 15 namespace v8 { | 16 namespace v8 { |
| 16 namespace internal { | 17 namespace internal { |
| 17 | 18 |
| 18 | 19 |
| 19 CodeStubDescriptor::CodeStubDescriptor(CodeStub* stub) | 20 CodeStubDescriptor::CodeStubDescriptor(CodeStub* stub) |
| 20 : call_descriptor_(stub->GetCallInterfaceDescriptor()), | 21 : call_descriptor_(stub->GetCallInterfaceDescriptor()), |
| 21 stack_parameter_count_(no_reg), | 22 stack_parameter_count_(no_reg), |
| 22 hint_stack_parameter_count_(-1), | 23 hint_stack_parameter_count_(-1), |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { | 252 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { |
| 252 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { | 253 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { |
| 253 BinaryOpICStub stub(isolate, | 254 BinaryOpICStub stub(isolate, |
| 254 static_cast<Token::Value>(op), | 255 static_cast<Token::Value>(op), |
| 255 static_cast<OverwriteMode>(mode)); | 256 static_cast<OverwriteMode>(mode)); |
| 256 stub.GetCode(); | 257 stub.GetCode(); |
| 257 } | 258 } |
| 258 } | 259 } |
| 259 | 260 |
| 260 // Generate special versions of the stub. | 261 // Generate special versions of the stub. |
| 261 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); | 262 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 262 } | 263 } |
| 263 | 264 |
| 264 | 265 |
| 265 void BinaryOpICStub::PrintState(OStream& os) const { // NOLINT | 266 void BinaryOpICStub::PrintState(OStream& os) const { // NOLINT |
| 266 os << state(); | 267 os << state(); |
| 267 } | 268 } |
| 268 | 269 |
| 269 | 270 |
| 270 // static | 271 // static |
| 271 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, | 272 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate, |
| 272 const BinaryOpIC::State& state) { | 273 const BinaryOpICState& state) { |
| 273 BinaryOpICStub stub(isolate, state); | 274 BinaryOpICStub stub(isolate, state); |
| 274 stub.GetCode(); | 275 stub.GetCode(); |
| 275 } | 276 } |
| 276 | 277 |
| 277 | 278 |
| 278 // static | 279 // static |
| 279 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 280 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
| 280 // Generate special versions of the stub. | 281 // Generate special versions of the stub. |
| 281 BinaryOpIC::State::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); | 282 BinaryOpICState::GenerateAheadOfTime(isolate, &GenerateAheadOfTime); |
| 282 } | 283 } |
| 283 | 284 |
| 284 | 285 |
| 285 void BinaryOpICWithAllocationSiteStub::PrintState( | 286 void BinaryOpICWithAllocationSiteStub::PrintState( |
| 286 OStream& os) const { // NOLINT | 287 OStream& os) const { // NOLINT |
| 287 os << state(); | 288 os << state(); |
| 288 } | 289 } |
| 289 | 290 |
| 290 | 291 |
| 291 // static | 292 // static |
| 292 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( | 293 void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( |
| 293 Isolate* isolate, const BinaryOpIC::State& state) { | 294 Isolate* isolate, const BinaryOpICState& state) { |
| 294 if (state.CouldCreateAllocationMementos()) { | 295 if (state.CouldCreateAllocationMementos()) { |
| 295 BinaryOpICWithAllocationSiteStub stub(isolate, state); | 296 BinaryOpICWithAllocationSiteStub stub(isolate, state); |
| 296 stub.GetCode(); | 297 stub.GetCode(); |
| 297 } | 298 } |
| 298 } | 299 } |
| 299 | 300 |
| 300 | 301 |
| 301 void StringAddStub::PrintBaseName(OStream& os) const { // NOLINT | 302 void StringAddStub::PrintBaseName(OStream& os) const { // NOLINT |
| 302 os << "StringAddStub"; | 303 os << "StringAddStub"; |
| 303 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { | 304 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { |
| 304 os << "_CheckBoth"; | 305 os << "_CheckBoth"; |
| 305 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { | 306 } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { |
| 306 os << "_CheckLeft"; | 307 os << "_CheckLeft"; |
| 307 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { | 308 } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { |
| 308 os << "_CheckRight"; | 309 os << "_CheckRight"; |
| 309 } | 310 } |
| 310 if (pretenure_flag() == TENURED) { | 311 if (pretenure_flag() == TENURED) { |
| 311 os << "_Tenured"; | 312 os << "_Tenured"; |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 | 315 |
| 315 | 316 |
| 316 InlineCacheState CompareICStub::GetICState() const { | 317 InlineCacheState CompareICStub::GetICState() const { |
| 317 CompareIC::State state = Max(left(), right()); | 318 CompareICState::State state = Max(left(), right()); |
| 318 switch (state) { | 319 switch (state) { |
| 319 case CompareIC::UNINITIALIZED: | 320 case CompareICState::UNINITIALIZED: |
| 320 return ::v8::internal::UNINITIALIZED; | 321 return ::v8::internal::UNINITIALIZED; |
| 321 case CompareIC::SMI: | 322 case CompareICState::SMI: |
| 322 case CompareIC::NUMBER: | 323 case CompareICState::NUMBER: |
| 323 case CompareIC::INTERNALIZED_STRING: | 324 case CompareICState::INTERNALIZED_STRING: |
| 324 case CompareIC::STRING: | 325 case CompareICState::STRING: |
| 325 case CompareIC::UNIQUE_NAME: | 326 case CompareICState::UNIQUE_NAME: |
| 326 case CompareIC::OBJECT: | 327 case CompareICState::OBJECT: |
| 327 case CompareIC::KNOWN_OBJECT: | 328 case CompareICState::KNOWN_OBJECT: |
| 328 return MONOMORPHIC; | 329 return MONOMORPHIC; |
| 329 case CompareIC::GENERIC: | 330 case CompareICState::GENERIC: |
| 330 return ::v8::internal::GENERIC; | 331 return ::v8::internal::GENERIC; |
| 331 } | 332 } |
| 332 UNREACHABLE(); | 333 UNREACHABLE(); |
| 333 return ::v8::internal::UNINITIALIZED; | 334 return ::v8::internal::UNINITIALIZED; |
| 334 } | 335 } |
| 335 | 336 |
| 336 | 337 |
| 338 Condition CompareICStub::GetCondition() const { |
| 339 return CompareIC::ComputeCondition(op()); |
| 340 } |
| 341 |
| 342 |
| 337 void CompareICStub::AddToSpecialCache(Handle<Code> new_object) { | 343 void CompareICStub::AddToSpecialCache(Handle<Code> new_object) { |
| 338 DCHECK(*known_map_ != NULL); | 344 DCHECK(*known_map_ != NULL); |
| 339 Isolate* isolate = new_object->GetIsolate(); | 345 Isolate* isolate = new_object->GetIsolate(); |
| 340 Factory* factory = isolate->factory(); | 346 Factory* factory = isolate->factory(); |
| 341 return Map::UpdateCodeCache(known_map_, | 347 return Map::UpdateCodeCache(known_map_, |
| 342 strict() ? | 348 strict() ? |
| 343 factory->strict_compare_ic_string() : | 349 factory->strict_compare_ic_string() : |
| 344 factory->compare_ic_string(), | 350 factory->compare_ic_string(), |
| 345 new_object); | 351 new_object); |
| 346 } | 352 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 369 DCHECK(state() == decode.state()); | 375 DCHECK(state() == decode.state()); |
| 370 #endif | 376 #endif |
| 371 return true; | 377 return true; |
| 372 } | 378 } |
| 373 return false; | 379 return false; |
| 374 } | 380 } |
| 375 | 381 |
| 376 | 382 |
| 377 void CompareICStub::Generate(MacroAssembler* masm) { | 383 void CompareICStub::Generate(MacroAssembler* masm) { |
| 378 switch (state()) { | 384 switch (state()) { |
| 379 case CompareIC::UNINITIALIZED: | 385 case CompareICState::UNINITIALIZED: |
| 380 GenerateMiss(masm); | 386 GenerateMiss(masm); |
| 381 break; | 387 break; |
| 382 case CompareIC::SMI: | 388 case CompareICState::SMI: |
| 383 GenerateSmis(masm); | 389 GenerateSmis(masm); |
| 384 break; | 390 break; |
| 385 case CompareIC::NUMBER: | 391 case CompareICState::NUMBER: |
| 386 GenerateNumbers(masm); | 392 GenerateNumbers(masm); |
| 387 break; | 393 break; |
| 388 case CompareIC::STRING: | 394 case CompareICState::STRING: |
| 389 GenerateStrings(masm); | 395 GenerateStrings(masm); |
| 390 break; | 396 break; |
| 391 case CompareIC::INTERNALIZED_STRING: | 397 case CompareICState::INTERNALIZED_STRING: |
| 392 GenerateInternalizedStrings(masm); | 398 GenerateInternalizedStrings(masm); |
| 393 break; | 399 break; |
| 394 case CompareIC::UNIQUE_NAME: | 400 case CompareICState::UNIQUE_NAME: |
| 395 GenerateUniqueNames(masm); | 401 GenerateUniqueNames(masm); |
| 396 break; | 402 break; |
| 397 case CompareIC::OBJECT: | 403 case CompareICState::OBJECT: |
| 398 GenerateObjects(masm); | 404 GenerateObjects(masm); |
| 399 break; | 405 break; |
| 400 case CompareIC::KNOWN_OBJECT: | 406 case CompareICState::KNOWN_OBJECT: |
| 401 DCHECK(*known_map_ != NULL); | 407 DCHECK(*known_map_ != NULL); |
| 402 GenerateKnownObjects(masm); | 408 GenerateKnownObjects(masm); |
| 403 break; | 409 break; |
| 404 case CompareIC::GENERIC: | 410 case CompareICState::GENERIC: |
| 405 GenerateGeneric(masm); | 411 GenerateGeneric(masm); |
| 406 break; | 412 break; |
| 407 } | 413 } |
| 408 } | 414 } |
| 409 | 415 |
| 410 | 416 |
| 411 void CompareNilICStub::UpdateStatus(Handle<Object> object) { | 417 void CompareNilICStub::UpdateStatus(Handle<Object> object) { |
| 412 State state = this->state(); | 418 State state = this->state(); |
| 413 DCHECK(!state.Contains(GENERIC)); | 419 DCHECK(!state.Contains(GENERIC)); |
| 414 State old_state = state; | 420 State old_state = state; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 } | 936 } |
| 931 | 937 |
| 932 | 938 |
| 933 InternalArrayConstructorStub::InternalArrayConstructorStub( | 939 InternalArrayConstructorStub::InternalArrayConstructorStub( |
| 934 Isolate* isolate) : PlatformCodeStub(isolate) { | 940 Isolate* isolate) : PlatformCodeStub(isolate) { |
| 935 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 941 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 936 } | 942 } |
| 937 | 943 |
| 938 | 944 |
| 939 } } // namespace v8::internal | 945 } } // namespace v8::internal |
| OLD | NEW |