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

« back to all changes in this revision

Viewing changes to src/v8.cc

  • 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:
47
47
static bool init_once_called = false;
48
48
 
49
49
bool V8::is_running_ = false;
50
 
bool V8::has_been_setup_ = false;
 
50
bool V8::has_been_set_up_ = false;
51
51
bool V8::has_been_disposed_ = false;
52
52
bool V8::has_fatal_error_ = false;
53
53
bool V8::use_crankshaft_ = true;
 
54
List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
54
55
 
55
56
static Mutex* entropy_mutex = OS::CreateMutex();
56
57
static EntropySource entropy_source;
57
58
 
58
59
 
59
60
bool V8::Initialize(Deserializer* des) {
60
 
  // Setting --harmony implies all other harmony flags.
61
 
  // TODO(rossberg): Is there a better place to put this?
62
 
  if (FLAG_harmony) {
63
 
    FLAG_harmony_typeof = true;
64
 
    FLAG_harmony_scoping = true;
65
 
    FLAG_harmony_proxies = true;
66
 
    FLAG_harmony_collections = true;
67
 
  }
 
61
  FlagList::EnforceFlagImplications();
68
62
 
69
63
  InitializeOncePerProcess();
70
64
 
88
82
  if (isolate->IsInitialized()) return true;
89
83
 
90
84
  is_running_ = true;
91
 
  has_been_setup_ = true;
 
85
  has_been_set_up_ = true;
92
86
  has_fatal_error_ = false;
93
87
  has_been_disposed_ = false;
94
88
 
106
100
  Isolate* isolate = Isolate::Current();
107
101
  ASSERT(isolate->IsDefaultIsolate());
108
102
 
109
 
  if (!has_been_setup_ || has_been_disposed_) return;
 
103
  if (!has_been_set_up_ || has_been_disposed_) return;
110
104
  isolate->TearDown();
111
105
 
112
106
  is_running_ = false;
113
107
  has_been_disposed_ = true;
 
108
 
 
109
  delete call_completed_callbacks_;
 
110
  call_completed_callbacks_ = NULL;
114
111
}
115
112
 
116
113
 
166
163
}
167
164
 
168
165
 
169
 
bool V8::IdleNotification() {
 
166
bool V8::IdleNotification(int hint) {
170
167
  // Returning true tells the caller that there is no need to call
171
168
  // IdleNotification again.
172
169
  if (!FLAG_use_idle_notification) return true;
173
170
 
174
171
  // Tell the heap that it may want to adjust.
175
 
  return HEAP->IdleNotification();
 
172
  return HEAP->IdleNotification(hint);
 
173
}
 
174
 
 
175
 
 
176
void V8::AddCallCompletedCallback(CallCompletedCallback callback) {
 
177
  if (call_completed_callbacks_ == NULL) {  // Lazy init.
 
178
    call_completed_callbacks_ = new List<CallCompletedCallback>();
 
179
  }
 
180
  for (int i = 0; i < call_completed_callbacks_->length(); i++) {
 
181
    if (callback == call_completed_callbacks_->at(i)) return;
 
182
  }
 
183
  call_completed_callbacks_->Add(callback);
 
184
}
 
185
 
 
186
 
 
187
void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) {
 
188
  if (call_completed_callbacks_ == NULL) return;
 
189
  for (int i = 0; i < call_completed_callbacks_->length(); i++) {
 
190
    if (callback == call_completed_callbacks_->at(i)) {
 
191
      call_completed_callbacks_->Remove(i);
 
192
    }
 
193
  }
 
194
}
 
195
 
 
196
 
 
197
void V8::FireCallCompletedCallback(Isolate* isolate) {
 
198
  if (call_completed_callbacks_ == NULL) return;
 
199
  HandleScopeImplementer* handle_scope_implementer =
 
200
      isolate->handle_scope_implementer();
 
201
  if (!handle_scope_implementer->CallDepthIsZero()) return;
 
202
  // Fire callbacks.  Increase call depth to prevent recursive callbacks.
 
203
  handle_scope_implementer->IncrementCallDepth();
 
204
  for (int i = 0; i < call_completed_callbacks_->length(); i++) {
 
205
    call_completed_callbacks_->at(i)();
 
206
  }
 
207
  handle_scope_implementer->DecrementCallDepth();
176
208
}
177
209
 
178
210
 
207
239
  if (init_once_called) return;
208
240
  init_once_called = true;
209
241
 
210
 
  // Setup the platform OS support.
211
 
  OS::Setup();
 
242
  // Set up the platform OS support.
 
243
  OS::SetUp();
212
244
 
213
245
  use_crankshaft_ = FLAG_crankshaft;
214
246
 
216
248
    use_crankshaft_ = false;
217
249
  }
218
250
 
219
 
  CPU::Setup();
 
251
  CPU::SetUp();
220
252
  if (!CPU::SupportsCrankshaft()) {
221
253
    use_crankshaft_ = false;
222
254
  }