~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to deps/v8/src/zone-inl.h

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2011 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
28
28
#ifndef V8_ZONE_INL_H_
29
29
#define V8_ZONE_INL_H_
30
30
 
 
31
#include "zone.h"
 
32
 
 
33
#include "counters.h"
31
34
#include "isolate.h"
32
 
#include "zone.h"
 
35
#include "utils.h"
33
36
#include "v8-counters.h"
34
37
 
35
38
namespace v8 {
36
39
namespace internal {
37
40
 
38
41
 
39
 
AssertNoZoneAllocation::AssertNoZoneAllocation()
40
 
    : prev_(Isolate::Current()->zone_allow_allocation()) {
41
 
  Isolate::Current()->set_zone_allow_allocation(false);
42
 
}
43
 
 
44
 
 
45
 
AssertNoZoneAllocation::~AssertNoZoneAllocation() {
46
 
  Isolate::Current()->set_zone_allow_allocation(prev_);
47
 
}
48
 
 
49
 
 
50
42
inline void* Zone::New(int size) {
51
 
  ASSERT(Isolate::Current()->zone_allow_allocation());
52
 
  ASSERT(ZoneScope::nesting() > 0);
 
43
  ASSERT(scope_nesting_ > 0);
53
44
  // Round up the requested size to fit the alignment.
54
45
  size = RoundUp(size, kAlignment);
55
46
 
 
47
  // If the allocation size is divisible by 8 then we return an 8-byte aligned
 
48
  // address.
 
49
  if (kPointerSize == 4 && kAlignment == 4) {
 
50
    position_ += ((~size) & 4) & (reinterpret_cast<intptr_t>(position_) & 4);
 
51
  } else {
 
52
    ASSERT(kAlignment >= kPointerSize);
 
53
  }
 
54
 
56
55
  // Check if the requested size is available without expanding.
57
56
  Address result = position_;
58
57
 
91
90
  // Reset the root to avoid unneeded iteration over all tree nodes
92
91
  // in the destructor.  For a zone-allocated tree, nodes will be
93
92
  // freed by the Zone.
94
 
  SplayTree<Config, ZoneListAllocationPolicy>::ResetRoot();
95
 
}
96
 
 
97
 
 
98
 
// TODO(isolates): for performance reasons, this should be replaced with a new
99
 
//                 operator that takes the zone in which the object should be
100
 
//                 allocated.
101
 
void* ZoneObject::operator new(size_t size) {
102
 
  return ZONE->New(static_cast<int>(size));
103
 
}
 
93
  SplayTree<Config, ZoneAllocationPolicy>::ResetRoot();
 
94
}
 
95
 
104
96
 
105
97
void* ZoneObject::operator new(size_t size, Zone* zone) {
106
98
  return zone->New(static_cast<int>(size));
107
99
}
108
100
 
109
 
 
110
 
inline void* ZoneListAllocationPolicy::New(int size) {
111
 
  return ZONE->New(size);
112
 
}
113
 
 
114
 
 
115
 
template <typename T>
116
 
void* ZoneList<T>::operator new(size_t size) {
117
 
  return ZONE->New(static_cast<int>(size));
 
101
inline void* ZoneAllocationPolicy::New(size_t size) {
 
102
  ASSERT(zone_);
 
103
  return zone_->New(static_cast<int>(size));
118
104
}
119
105
 
120
106
 
124
110
}
125
111
 
126
112
 
127
 
ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode)
128
 
    : isolate_(isolate), mode_(mode) {
129
 
  isolate_->zone()->scope_nesting_++;
 
113
ZoneScope::ZoneScope(Zone* zone, ZoneScopeMode mode)
 
114
    : zone_(zone), mode_(mode) {
 
115
  zone_->scope_nesting_++;
130
116
}
131
117
 
132
118
 
133
119
bool ZoneScope::ShouldDeleteOnExit() {
134
 
  return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT;
135
 
}
136
 
 
137
 
 
138
 
int ZoneScope::nesting() {
139
 
  return Isolate::Current()->zone()->scope_nesting_;
 
120
  return zone_->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT;
140
121
}
141
122
 
142
123