| OLD | NEW | 
|    1 // Copyright 2008 the V8 project authors. All rights reserved. |    1 // Copyright 2008 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  304      context_.Reset(isolate, context); |  304      context_.Reset(isolate, context); | 
|  305      context->Enter(); |  305      context->Enter(); | 
|  306      // We can't do this later perhaps because of a fatal error. |  306      // We can't do this later perhaps because of a fatal error. | 
|  307      isolate_ = isolate; |  307      isolate_ = isolate; | 
|  308   } |  308   } | 
|  309  |  309  | 
|  310   v8::Persistent<v8::Context> context_; |  310   v8::Persistent<v8::Context> context_; | 
|  311   v8::Isolate* isolate_; |  311   v8::Isolate* isolate_; | 
|  312 }; |  312 }; | 
|  313  |  313  | 
 |  314  | 
 |  315 static inline uint16_t* AsciiToTwoByteString(const char* source) { | 
 |  316   int array_length = i::StrLength(source) + 1; | 
 |  317   uint16_t* converted = i::NewArray<uint16_t>(array_length); | 
 |  318   for (int i = 0; i < array_length; i++) converted[i] = source[i]; | 
 |  319   return converted; | 
 |  320 } | 
 |  321  | 
 |  322  | 
|  314 static inline v8::Local<v8::Value> v8_num(double x) { |  323 static inline v8::Local<v8::Value> v8_num(double x) { | 
|  315   return v8::Number::New(v8::Isolate::GetCurrent(), x); |  324   return v8::Number::New(v8::Isolate::GetCurrent(), x); | 
|  316 } |  325 } | 
|  317  |  326  | 
|  318  |  327  | 
|  319 static inline v8::Local<v8::String> v8_str(const char* x) { |  328 static inline v8::Local<v8::String> v8_str(const char* x) { | 
|  320   return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x); |  329   return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x); | 
|  321 } |  330 } | 
|  322  |  331  | 
|  323  |  332  | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  396       ->Run(); |  405       ->Run(); | 
|  397 } |  406 } | 
|  398  |  407  | 
|  399  |  408  | 
|  400 static inline v8::Local<v8::Value> CompileRunWithOrigin( |  409 static inline v8::Local<v8::Value> CompileRunWithOrigin( | 
|  401     const char* source, const char* origin_url) { |  410     const char* source, const char* origin_url) { | 
|  402   return CompileRunWithOrigin(v8_str(source), origin_url); |  411   return CompileRunWithOrigin(v8_str(source), origin_url); | 
|  403 } |  412 } | 
|  404  |  413  | 
|  405  |  414  | 
 |  415  | 
 |  416 static inline void ExpectString(const char* code, const char* expected) { | 
 |  417   v8::Local<v8::Value> result = CompileRun(code); | 
 |  418   CHECK(result->IsString()); | 
 |  419   v8::String::Utf8Value utf8(result); | 
 |  420   CHECK_EQ(expected, *utf8); | 
 |  421 } | 
 |  422  | 
 |  423  | 
 |  424 static inline void ExpectInt32(const char* code, int expected) { | 
 |  425   v8::Local<v8::Value> result = CompileRun(code); | 
 |  426   CHECK(result->IsInt32()); | 
 |  427   CHECK_EQ(expected, result->Int32Value()); | 
 |  428 } | 
 |  429  | 
 |  430  | 
 |  431 static inline void ExpectBoolean(const char* code, bool expected) { | 
 |  432   v8::Local<v8::Value> result = CompileRun(code); | 
 |  433   CHECK(result->IsBoolean()); | 
 |  434   CHECK_EQ(expected, result->BooleanValue()); | 
 |  435 } | 
 |  436  | 
 |  437  | 
 |  438 static inline void ExpectTrue(const char* code) { | 
 |  439   ExpectBoolean(code, true); | 
 |  440 } | 
 |  441  | 
 |  442  | 
 |  443 static inline void ExpectFalse(const char* code) { | 
 |  444   ExpectBoolean(code, false); | 
 |  445 } | 
 |  446  | 
 |  447  | 
 |  448 static inline void ExpectObject(const char* code, | 
 |  449                                 v8::Local<v8::Value> expected) { | 
 |  450   v8::Local<v8::Value> result = CompileRun(code); | 
 |  451   CHECK(result->SameValue(expected)); | 
 |  452 } | 
 |  453  | 
 |  454  | 
 |  455 static inline void ExpectUndefined(const char* code) { | 
 |  456   v8::Local<v8::Value> result = CompileRun(code); | 
 |  457   CHECK(result->IsUndefined()); | 
 |  458 } | 
 |  459  | 
 |  460  | 
|  406 // Helper function that simulates a full new-space in the heap. |  461 // Helper function that simulates a full new-space in the heap. | 
|  407 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { |  462 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { | 
|  408   int new_linear_size = static_cast<int>( |  463   int new_linear_size = static_cast<int>( | 
|  409       *space->allocation_limit_address() - *space->allocation_top_address()); |  464       *space->allocation_limit_address() - *space->allocation_top_address()); | 
|  410   if (new_linear_size == 0) return; |  465   if (new_linear_size == 0) return; | 
|  411   v8::internal::AllocationResult allocation = |  466   v8::internal::AllocationResult allocation = | 
|  412       space->AllocateRaw(new_linear_size); |  467       space->AllocateRaw(new_linear_size); | 
|  413   v8::internal::FreeListNode* node = |  468   v8::internal::FreeListNode* node = | 
|  414       v8::internal::FreeListNode::cast(allocation.ToObjectChecked()); |  469       v8::internal::FreeListNode::cast(allocation.ToObjectChecked()); | 
|  415   node->set_size(space->heap(), new_linear_size); |  470   node->set_size(space->heap(), new_linear_size); | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|  440     CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); |  495     CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | 
|  441     heap_profiler_->StopHeapObjectsTracking(); |  496     heap_profiler_->StopHeapObjectsTracking(); | 
|  442   } |  497   } | 
|  443  |  498  | 
|  444  private: |  499  private: | 
|  445   i::HeapProfiler* heap_profiler_; |  500   i::HeapProfiler* heap_profiler_; | 
|  446 }; |  501 }; | 
|  447  |  502  | 
|  448  |  503  | 
|  449 #endif  // ifndef CCTEST_H_ |  504 #endif  // ifndef CCTEST_H_ | 
| OLD | NEW |