~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to src/heap-inl.h

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    NewSpacePage* rear_page =
50
50
        NewSpacePage::FromAddress(reinterpret_cast<Address>(rear_));
51
51
    ASSERT(!rear_page->prev_page()->is_anchor());
52
 
    rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->body_limit());
 
52
    rear_ = reinterpret_cast<intptr_t*>(rear_page->prev_page()->area_end());
53
53
    ActivateGuardIfOnTheSamePage();
54
54
  }
55
55
 
81
81
}
82
82
 
83
83
 
84
 
int Heap::MaxObjectSizeInPagedSpace() {
85
 
  return Page::kMaxHeapObjectSize;
86
 
}
87
 
 
88
 
 
89
84
MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
90
85
                                          PretenureFlag pretenure) {
91
86
  // Check for ASCII first since this is the common case.
119
114
 
120
115
  // Allocate string.
121
116
  Object* result;
122
 
  { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace())
 
117
  { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize)
123
118
                   ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE)
124
119
                   : old_data_space_->AllocateRaw(size);
125
120
    if (!maybe_result->ToObject(&result)) return maybe_result;
126
121
  }
127
122
 
128
 
  reinterpret_cast<HeapObject*>(result)->set_map(map);
 
123
  // String maps are all immortal immovable objects.
 
124
  reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map);
129
125
  // Set length and hash fields of the allocated string.
130
126
  String* answer = String::cast(result);
131
127
  answer->set_length(str.length());
152
148
 
153
149
  // Allocate string.
154
150
  Object* result;
155
 
  { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace())
 
151
  { MaybeObject* maybe_result = (size > Page::kMaxNonCodeHeapObjectSize)
156
152
                   ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE)
157
153
                   : old_data_space_->AllocateRaw(size);
158
154
    if (!maybe_result->ToObject(&result)) return maybe_result;
437
433
}
438
434
 
439
435
 
440
 
bool Heap::CollectGarbage(AllocationSpace space) {
441
 
  return CollectGarbage(space, SelectGarbageCollector(space));
 
436
bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) {
 
437
  const char* collector_reason = NULL;
 
438
  GarbageCollector collector = SelectGarbageCollector(space, &collector_reason);
 
439
  return CollectGarbage(space, collector, gc_reason, collector_reason);
442
440
}
443
441
 
444
442
 
462
460
 
463
461
 
464
462
int Heap::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) {
465
 
  ASSERT(HasBeenSetup());
 
463
  ASSERT(HasBeenSetUp());
466
464
  int amount = amount_of_external_allocated_memory_ + change_in_bytes;
467
465
  if (change_in_bytes >= 0) {
468
466
    // Avoid overflow.
473
471
        amount_of_external_allocated_memory_ -
474
472
        amount_of_external_allocated_memory_at_last_global_gc_;
475
473
    if (amount_since_last_global_gc > external_allocation_limit_) {
476
 
      CollectAllGarbage(kNoGCFlags);
 
474
      CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached");
477
475
    }
478
476
  } else {
479
477
    // Avoid underflow.
504
502
#define GC_GREEDY_CHECK() { }
505
503
#endif
506
504
 
507
 
 
508
505
// Calls the FUNCTION_CALL function and retries it up to three times
509
506
// to guarantee that any allocations performed during the call will
510
507
// succeed if there's enough memory.
523
520
    }                                                                     \
524
521
    if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY;                \
525
522
    ISOLATE->heap()->CollectGarbage(Failure::cast(__maybe_object__)->     \
526
 
                                    allocation_space());                  \
 
523
                                    allocation_space(),                   \
 
524
                                    "allocation failure");                \
527
525
    __maybe_object__ = FUNCTION_CALL;                                     \
528
526
    if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE;            \
529
527
    if (__maybe_object__->IsOutOfMemory()) {                              \
531
529
    }                                                                     \
532
530
    if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY;                \
533
531
    ISOLATE->counters()->gc_last_resort_from_handles()->Increment();      \
534
 
    ISOLATE->heap()->CollectAllAvailableGarbage();                        \
 
532
    ISOLATE->heap()->CollectAllAvailableGarbage("last resort gc");        \
535
533
    {                                                                     \
536
534
      AlwaysAllocateScope __scope__;                                      \
537
535
      __maybe_object__ = FUNCTION_CALL;                                   \