Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim: add test/addons dependency stubs
Browse files Browse the repository at this point in the history
New `test/addons` tests include dependencies on unimplemented GC/Profiler
interfaces. Add stubs to unblock these tests. Still unimplemented as
JSRT does not yet have profiler APIs.

PR-URL: #52
Reviewed-By: Sandeep Agarwal <Agarwal.Sandeep@microsoft.com>
  • Loading branch information
Jianchun Xu committed Apr 6, 2016
1 parent 0cd4cb8 commit 313cec1
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
62 changes: 62 additions & 0 deletions deps/chakrashim/include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

namespace v8 {

struct HeapStatsUpdate;

// NOT IMPLEMENTED
class V8_EXPORT CpuProfiler {
public:
Expand All @@ -39,11 +41,63 @@ class V8_EXPORT CpuProfiler {
void SetIdle(bool is_idle) {}
};

class V8_EXPORT OutputStream { // NOLINT
public:
enum WriteResult {
kContinue = 0,
kAbort = 1
};
virtual ~OutputStream() {}
virtual void EndOfStream() = 0;
virtual int GetChunkSize() { return 1024; }
virtual WriteResult WriteAsciiChunk(char* data, int size) = 0;
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) {
return kAbort;
}
};

// NOT IMPLEMENTED
class V8_EXPORT HeapSnapshot {
public:
enum SerializationFormat {
kJSON = 0 // See format description near 'Serialize' method.
};

void Delete() { delete this; }
void Serialize(OutputStream* stream,
SerializationFormat format = kJSON) const {}
};

class V8_EXPORT ActivityControl { // NOLINT
public:
enum ControlOption {
kContinue = 0,
kAbort = 1
};
virtual ~ActivityControl() {}
virtual ControlOption ReportProgressValue(int done, int total) = 0;
};

// NOT IMPLEMENTED
class V8_EXPORT HeapProfiler {
public:
typedef RetainedObjectInfo *(*WrapperInfoCallback)(
uint16_t class_id, Handle<Value> wrapper);

class ObjectNameResolver {
public:
virtual const char* GetName(Local<Object> object) = 0;

protected:
virtual ~ObjectNameResolver() {}
};

const HeapSnapshot* TakeHeapSnapshot(
ActivityControl* control = NULL,
ObjectNameResolver* global_object_name_resolver = NULL) {
return new HeapSnapshot();
}

void SetWrapperClassInfoProvider(
uint16_t class_id, WrapperInfoCallback callback) {}
void StartTrackingHeapObjects(bool track_allocations = false) {}
Expand All @@ -61,4 +115,12 @@ class V8_EXPORT RetainedObjectInfo {
virtual intptr_t GetSizeInBytes() { return 0; }
};

struct HeapStatsUpdate {
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
: index(index), count(count), size(size) { }
uint32_t index; // Index of the time interval that was changed.
uint32_t count; // New value of count field for the interval with this index.
uint32_t size; // New value of size field for the interval with this index.
};

} // namespace v8
6 changes: 6 additions & 0 deletions deps/chakrashim/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,11 @@ class V8_EXPORT Isolate {
Scope& operator=(const Scope&);
};

enum GarbageCollectionType {
kFullGarbageCollection,
kMinorGarbageCollection
};

static Isolate* New(const CreateParams& params);
static Isolate* New();
static Isolate* GetCurrent();
Expand Down Expand Up @@ -2215,6 +2220,7 @@ class V8_EXPORT Isolate {

void CancelTerminateExecution();
void TerminateExecution();
void RequestGarbageCollectionForTesting(GarbageCollectionType type);

void SetCounterFunction(CounterLookupCallback);
void SetCreateHistogramFunction(CreateHistogramCallback);
Expand Down
4 changes: 4 additions & 0 deletions deps/chakrashim/src/v8isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ void Isolate::TerminateExecution() {
jsrt::IsolateShim::FromIsolate(this)->DisableExecution();
}

void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) {
JsCollectGarbage(jsrt::IsolateShim::FromIsolate(this)->GetRuntimeHandle());
}

void Isolate::SetCounterFunction(CounterLookupCallback) {
CHAKRA_UNIMPLEMENTED();
}
Expand Down

0 comments on commit 313cec1

Please sign in to comment.