Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 // may not have TLS initialized yet. However, in initializing APIs it | 297 // may not have TLS initialized yet. However, in initializing APIs it |
| 298 // may be too early to call EnsureInitialized() - some pre-init | 298 // may be too early to call EnsureInitialized() - some pre-init |
| 299 // parameters still have to be configured. | 299 // parameters still have to be configured. |
| 300 static inline i::Isolate* EnterIsolateIfNeeded() { | 300 static inline i::Isolate* EnterIsolateIfNeeded() { |
| 301 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 301 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 302 if (isolate != NULL) | 302 if (isolate != NULL) |
| 303 return isolate; | 303 return isolate; |
| 304 | 304 |
| 305 i::Isolate::EnterDefaultIsolate(); | 305 i::Isolate::EnterDefaultIsolate(); |
| 306 isolate = i::Isolate::Current(); | 306 isolate = i::Isolate::Current(); |
| 307 return isolate; | 307 return isolate; |
|
danno
2011/11/15 09:46:47
nit: indent
| |
| 308 } | 308 } |
| 309 | 309 |
| 310 | 310 |
| 311 StartupDataDecompressor::StartupDataDecompressor() | 311 StartupDataDecompressor::StartupDataDecompressor() |
| 312 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) { | 312 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) { |
| 313 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { | 313 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { |
| 314 raw_data[i] = NULL; | 314 raw_data[i] = NULL; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); | 479 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); |
| 480 } | 480 } |
| 481 return v8::Undefined(); | 481 return v8::Undefined(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 | 484 |
| 485 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; | 485 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; |
| 486 | 486 |
| 487 | 487 |
| 488 RegisteredExtension::RegisteredExtension(Extension* extension) | 488 RegisteredExtension::RegisteredExtension(Extension* extension) |
| 489 : extension_(extension), state_(UNVISITED) { } | 489 : extension_(extension) { } |
| 490 | 490 |
| 491 | 491 |
| 492 void RegisteredExtension::Register(RegisteredExtension* that) { | 492 void RegisteredExtension::Register(RegisteredExtension* that) { |
| 493 that->next_ = first_extension_; | 493 that->next_ = first_extension_; |
| 494 first_extension_ = that; | 494 first_extension_ = that; |
| 495 } | 495 } |
| 496 | 496 |
| 497 | 497 |
| 498 void RegisterExtension(Extension* that) { | 498 void RegisterExtension(Extension* that) { |
| 499 RegisteredExtension* extension = new RegisteredExtension(that); | 499 RegisteredExtension* extension = new RegisteredExtension(that); |
| 500 RegisteredExtension::Register(extension); | 500 RegisteredExtension::Register(extension); |
| 501 } | 501 } |
| 502 | 502 |
| 503 | 503 |
| 504 namespace internal { | |
| 505 | |
|
Vitaly Repeshko
2011/11/15 18:14:17
nit: Remove one blank line.
| |
| 506 | |
| 507 static uint32_t Hash(RegisteredExtension* extension) { | |
| 508 return v8::internal::ComputeIntegerHash( | |
| 509 reinterpret_cast<uint32_t>(extension)); | |
|
Vitaly Repeshko
2011/11/15 18:14:17
I'm not sure it'll work with 64 bit pointers. I th
| |
| 510 } | |
| 511 | |
| 512 static bool MatchRegisteredExtensions(void* key1, void* key2) { | |
| 513 return key1 == key2; | |
| 514 } | |
| 515 | |
| 516 static Allocator* ExtensionStatesAllocator() { | |
| 517 static Allocator default_allocator; | |
|
Vitaly Repeshko
2011/11/15 18:14:17
Allocate the allocator with "new" to avoid issues
| |
| 518 return &default_allocator; | |
| 519 } | |
| 520 | |
| 521 ExtensionStates::ExtensionStates() | |
| 522 : HashMap(MatchRegisteredExtensions, ExtensionStatesAllocator(), 8) | |
| 523 {} | |
| 524 | |
| 525 ExtensionTraversalState ExtensionStates::get_state( | |
| 526 RegisteredExtension* extension) { | |
| 527 i::HashMap::Entry* entry = Lookup(extension, Hash(extension), false); | |
| 528 if (entry == NULL) { | |
| 529 entry = Lookup(extension, Hash(extension), true); | |
|
Vitaly Repeshko
2011/11/15 18:14:17
Can't you simply return UNVISITED?
| |
| 530 entry->value = reinterpret_cast<void*>( | |
| 531 static_cast<int>(UNVISITED)); | |
| 532 } | |
| 533 return static_cast<ExtensionTraversalState>( | |
| 534 reinterpret_cast<int>(entry->value)); | |
|
Vitaly Repeshko
2011/11/15 18:14:17
Again, I think it has to be something like static_
| |
| 535 } | |
| 536 | |
| 537 void ExtensionStates::set_state(RegisteredExtension* extension, | |
| 538 ExtensionTraversalState state) { | |
| 539 Lookup(extension, Hash(extension), true)->value = | |
| 540 reinterpret_cast<void*>(static_cast<int>(state)); | |
| 541 } | |
| 542 } | |
|
Vitaly Repeshko
2011/11/15 18:14:17
nit: // namespace internal
| |
| 543 | |
| 504 Extension::Extension(const char* name, | 544 Extension::Extension(const char* name, |
| 505 const char* source, | 545 const char* source, |
| 506 int dep_count, | 546 int dep_count, |
| 507 const char** deps, | 547 const char** deps, |
| 508 int source_length) | 548 int source_length) |
| 509 : name_(name), | 549 : name_(name), |
| 510 source_length_(source_length >= 0 ? | 550 source_length_(source_length >= 0 ? |
| 511 source_length : (source ? strlen(source) : 0)), | 551 source_length : (source ? strlen(source) : 0)), |
| 512 source_(source, source_length_), | 552 source_(source, source_length_), |
| 513 dep_count_(dep_count), | 553 dep_count_(dep_count), |
| (...skipping 5603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6117 | 6157 |
| 6118 | 6158 |
| 6119 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6159 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 6120 HandleScopeImplementer* scope_implementer = | 6160 HandleScopeImplementer* scope_implementer = |
| 6121 reinterpret_cast<HandleScopeImplementer*>(storage); | 6161 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 6122 scope_implementer->IterateThis(v); | 6162 scope_implementer->IterateThis(v); |
| 6123 return storage + ArchiveSpacePerThread(); | 6163 return storage + ArchiveSpacePerThread(); |
| 6124 } | 6164 } |
| 6125 | 6165 |
| 6126 } } // namespace v8::internal | 6166 } } // namespace v8::internal |
| OLD | NEW |